Skip to content

Commit b4ee8c4

Browse files
authored
Merge pull request #30564 from barttom/fix/29211/remove-delay-visibility-chat-input-after-editing-message
fix: change moment of displaying chat after editing existed message
2 parents 7457e5a + c47a6fe commit b4ee8c4

File tree

4 files changed

+42
-29
lines changed

4 files changed

+42
-29
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import setShouldShowComposeInputKeyboardAwareBuilder from './setShouldShowComposeInputKeyboardAwareBuilder';
2+
3+
export default setShouldShowComposeInputKeyboardAwareBuilder('keyboardDidHide');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import setShouldShowComposeInputKeyboardAwareBuilder from './setShouldShowComposeInputKeyboardAwareBuilder';
2+
3+
// On iOS, there is a visible delay in displaying input after the keyboard has been closed with the `keyboardDidHide` event
4+
// Because of that - on iOS we can use `keyboardWillHide` that is not available on android
5+
export default setShouldShowComposeInputKeyboardAwareBuilder('keyboardWillHide');

src/libs/setShouldShowComposeInputKeyboardAware/index.native.ts

-29
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {EmitterSubscription, Keyboard} from 'react-native';
2+
import {KeyboardEventName} from 'react-native/Libraries/Components/Keyboard/Keyboard';
3+
import * as Composer from '@userActions/Composer';
4+
import SetShouldShowComposeInputKeyboardAware from './types';
5+
6+
let keyboardEventListener: EmitterSubscription | null = null;
7+
// On iOS, there is a visible delay in displaying input after the keyboard has been closed with the `keyboardDidHide` event
8+
// Because of that - on iOS we can use `keyboardWillHide` that is not available on android
9+
10+
const setShouldShowComposeInputKeyboardAwareBuilder: (keyboardEvent: KeyboardEventName) => SetShouldShowComposeInputKeyboardAware =
11+
(keyboardEvent: KeyboardEventName) => (shouldShow: boolean) => {
12+
if (keyboardEventListener) {
13+
keyboardEventListener.remove();
14+
keyboardEventListener = null;
15+
}
16+
17+
if (!shouldShow) {
18+
Composer.setShouldShowComposeInput(false);
19+
return;
20+
}
21+
22+
// If keyboard is already hidden, we should show composer immediately because keyboardDidHide event won't be called
23+
if (!Keyboard.isVisible()) {
24+
Composer.setShouldShowComposeInput(true);
25+
return;
26+
}
27+
28+
keyboardEventListener = Keyboard.addListener(keyboardEvent, () => {
29+
Composer.setShouldShowComposeInput(true);
30+
keyboardEventListener?.remove();
31+
});
32+
};
33+
34+
export default setShouldShowComposeInputKeyboardAwareBuilder;

0 commit comments

Comments
 (0)