Fix RHS reply input focus issues (#33965) (#34099)

Automatic Merge
Этот коммит содержится в:
Mattermost Build
2025-10-09 12:13:38 +03:00
коммит произвёл GitHub
родитель 375ce229f4
Коммит 967e44805b
4 изменённых файлов: 78 добавлений и 7 удалений

Просмотреть файл

@@ -236,7 +236,9 @@ describe('components/avanced_text_editor/advanced_text_editor', () => {
expect(textbox).not.toHaveFocus();
// save is called with a short delayed after pressing escape key
jest.advanceTimersByTime(Constants.SAVE_DRAFT_TIMEOUT + 50);
act(() => {
jest.advanceTimersByTime(Constants.SAVE_DRAFT_TIMEOUT + 50);
});
expect(mockedRemoveDraft).toHaveBeenCalled();
expect(mockedUpdateDraft).not.toHaveBeenCalled();
});

Просмотреть файл

@@ -33,11 +33,20 @@ const useTextboxFocus = (
const focusTextbox = useCallback((keepFocus = false) => {
const postTextboxDisabled = !canPost;
if (textboxRef.current && postTextboxDisabled) {
textboxRef.current.blur(); // Fixes Firefox bug which causes keyboard shortcuts to be ignored (MM-22482)
// Fixes Firefox bug which causes keyboard shortcuts to be ignored (MM-22482)
requestAnimationFrame(() => {
textboxRef.current?.blur();
});
return;
}
if (textboxRef.current && (keepFocus || !UserAgent.isMobile())) {
textboxRef.current.focus();
// Focus immediately, so we capture any typed text.
textboxRef.current?.focus();
// Also re-focus after the next animation frame, to work around issues where the RHS is "opening".
requestAnimationFrame(() => {
textboxRef.current?.focus();
});
}
}, [canPost, textboxRef]);