Clean up inviteLink handling, harden compose input

This commit is contained in:
Scott Nonnenberg 2021-05-06 12:06:20 -07:00 committed by GitHub
parent 986d8a66bc
commit fc12d02a8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 59 additions and 3 deletions

View file

@ -76,6 +76,7 @@ export type Props = {
onSubmit(message: string, mentions: Array<BodyRangeType>): unknown;
getQuotedMessage(): unknown;
clearQuotedMessage(): unknown;
setSecureInput(enabled: boolean): unknown;
};
const MAX_LENGTH = 64 * 1024;
@ -103,6 +104,7 @@ export const CompositionInput: React.ComponentType<Props> = props => {
skinTone,
draftText,
draftBodyRanges,
setSecureInput,
getQuotedMessage,
clearQuotedMessage,
sortedGroupMembers,
@ -259,6 +261,20 @@ export const CompositionInput: React.ComponentType<Props> = props => {
return false;
};
const onFocus = (): void => {
setSecureInput(true);
};
const onBlur = (): void => {
setSecureInput(false);
};
React.useEffect(() => {
return () => {
setSecureInput(false);
};
}, [setSecureInput]);
const onEnter = (): boolean => {
const quill = quillRef.current;
const emojiCompletion = emojiCompletionRef.current;
@ -494,6 +510,8 @@ export const CompositionInput: React.ComponentType<Props> = props => {
onChange,
onEnter,
onEscape,
onFocus,
onBlur,
onPickEmoji,
onShortKeyEnter,
onTab,
@ -508,6 +526,8 @@ export const CompositionInput: React.ComponentType<Props> = props => {
return (
<ReactQuill
className="module-composition-input__quill"
onFocus={() => callbacksRef.current.onFocus()}
onBlur={() => callbacksRef.current.onBlur()}
onChange={() => callbacksRef.current.onChange()}
defaultValue={delta}
modules={{