Fix Composer: Unable to hide text formatter (#1002)
This commit is contained in:
parent
0b44dfa883
commit
4f632f0aaf
@ -56,6 +56,19 @@ const TEXT_FORMATTER_SAFE_AREA_PX = 90;
|
|||||||
// For some reason Safari inserts `<br>` after user removes text from input
|
// For some reason Safari inserts `<br>` after user removes text from input
|
||||||
const SAFARI_BR = '<br>';
|
const SAFARI_BR = '<br>';
|
||||||
|
|
||||||
|
function clearSelection() {
|
||||||
|
const selection = window.getSelection();
|
||||||
|
if (!selection) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selection.removeAllRanges) {
|
||||||
|
selection.removeAllRanges();
|
||||||
|
} else if (selection.empty) {
|
||||||
|
selection.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const MessageInput: FC<OwnProps & StateProps & DispatchProps> = ({
|
const MessageInput: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||||
id,
|
id,
|
||||||
editableInputId,
|
editableInputId,
|
||||||
@ -106,6 +119,11 @@ const MessageInput: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
focusEditableElement(inputRef.current!);
|
focusEditableElement(inputRef.current!);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleCloseTextFormatter = useCallback(() => {
|
||||||
|
closeTextFormatter();
|
||||||
|
clearSelection();
|
||||||
|
}, [closeTextFormatter]);
|
||||||
|
|
||||||
function checkSelection() {
|
function checkSelection() {
|
||||||
// Disable the formatter on iOS devices for now.
|
// Disable the formatter on iOS devices for now.
|
||||||
if (IS_IOS) {
|
if (IS_IOS) {
|
||||||
@ -326,7 +344,7 @@ const MessageInput: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
isOpen={isTextFormatterOpen}
|
isOpen={isTextFormatterOpen}
|
||||||
anchorPosition={textFormatterAnchorPosition}
|
anchorPosition={textFormatterAnchorPosition}
|
||||||
selectedRange={selectedRange}
|
selectedRange={selectedRange}
|
||||||
onClose={closeTextFormatter}
|
onClose={handleCloseTextFormatter}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user