Merge pull request #4826 from urbit/james/chatinput

chat: persist submit button
This commit is contained in:
matildepark 2021-04-26 15:55:26 -04:00 committed by GitHub
commit a77fa96f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 19 deletions

View File

@ -44,7 +44,7 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
inCodeMode: false,
submitFocus: false,
uploadingPaste: false,
currentInput: props.message,
currentInput: props.message
};
this.chatEditor = React.createRef();
@ -125,10 +125,6 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
});
}
toggleFocus(value) {
this.setState({ submitFocus: value });
}
eventHandler(value) {
this.setState({ currentInput: value });
}
@ -194,8 +190,6 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
onUnmount={props.onUnmount}
message={props.message}
onPaste={this.onPaste.bind(this)}
focusEvent={() => this.toggleFocus(true)}
blurEvent={() => this.toggleFocus(false)}
changeEvent={this.eventHandler}
placeholder='Message...'
/>
@ -224,9 +218,7 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
)
) : null}
</Box>
{(MOBILE_BROWSER_REGEX.test(navigator.userAgent) &&
state.submitFocus) ||
state.currentInput !== "" ? (
{MOBILE_BROWSER_REGEX.test(navigator.userAgent) ?
<Box
ml={2}
mr="12px"
@ -237,13 +229,13 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
width="24px"
height="24px"
borderRadius="50%"
backgroundColor={state.currentInput !== "" ? "blue" : "gray"}
cursor={state.currentInput !== "" ? "pointer" : "default"}
backgroundColor={state.currentInput !== '' ? 'blue' : 'gray'}
cursor={state.currentInput !== '' ? 'pointer' : 'default'}
onClick={() => this.chatEditor.current.submit()}
>
<Icon icon="ArrowEast" color="white" />
</Box>
) : null}
: null}
</Row>
);
}

View File

@ -181,8 +181,6 @@ export default class ChatEditor extends Component {
inCodeMode,
placeholder,
message,
focusEvent,
blurEvent,
...props
} = this.props;
@ -242,8 +240,6 @@ export default class ChatEditor extends Component {
rows="1"
style={{ width: '100%', background: 'transparent', color: 'currentColor' }}
placeholder={inCodeMode ? "Code..." : "Message..."}
onFocus={focusEvent}
onBlur={blurEvent}
onChange={event => {
this.messageChange(null, null, event.target.value);
}}
@ -271,8 +267,6 @@ export default class ChatEditor extends Component {
this.editor = editor;
editor.focus();
}}
onFocus={focusEvent}
onBlur={blurEvent}
{...props}
/>
}