Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as Browser from '@libs/Browser';
import updateIsFullComposerAvailable from '@libs/ComposerUtils/updateIsFullComposerAvailable';
import * as EmojiUtils from '@libs/EmojiUtils';
import * as FileUtils from '@libs/fileDownload/FileUtils';
import focusComposerWithDelay from '@libs/focusComposerWithDelay';
import isEnterWhileComposition from '@libs/KeyboardShortcut/isEnterWhileComposition';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -413,7 +414,7 @@ function Composer(
return;
}

textInput.current.focus();
focusComposerWithDelay(textInput.current)(true);
});

props.onFocus?.(e);
Expand Down
5 changes: 4 additions & 1 deletion src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ function BaseModal(
avoidKeyboard={avoidKeyboard}
customBackdrop={shouldUseCustomBackdrop ? <Overlay onPress={handleBackdropPress} /> : undefined}
>
<ModalContent onDismiss={handleDismissModal}>
<ModalContent
onModalWillShow={saveFocusState}
onDismiss={handleDismissModal}
>
<PortalHost name="modal" />
<FocusTrapForModal
active={isVisible}
Expand Down
12 changes: 9 additions & 3 deletions src/components/Modal/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ type ModalContentProps = {
* such as closing the attachment modal through the browser's back button.
* */
onDismiss: () => void;

/** Callback method fired after modal content is mounted. */
onModalWillShow: () => void;
};

function ModalContent({children, onDismiss = () => {}}: ModalContentProps) {
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
React.useEffect(() => () => onDismiss?.(), []);
function ModalContent({children, onDismiss = () => {}, onModalWillShow = () => {}}: ModalContentProps) {
React.useEffect(() => {
onModalWillShow();
return onDismiss;
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);
return children;
}
ModalContent.displayName = 'ModalContent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function ComposerWithSuggestions(
const valueRef = useRef(value);
valueRef.current = value;

const [selection, setSelection] = useState<TextSelection>(() => ({start: 0, end: 0, positionX: 0, positionY: 0}));
const [selection, setSelection] = useState<TextSelection>(() => ({start: value.length, end: value.length, positionX: 0, positionY: 0}));

const [composerHeight, setComposerHeight] = useState(0);

Expand Down Expand Up @@ -562,7 +562,7 @@ function ComposerWithSuggestions(
return;
}

focus(false);
focus(true);
}, true);
}, [focus, isFocused]);

Expand Down