mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
set message on enter
This commit is contained in:
parent
f01dab52b6
commit
43d88b5a64
@ -27,12 +27,21 @@ export function AddTopic() {
|
||||
actions.addTopic();
|
||||
}
|
||||
|
||||
const onKey = (e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
if (state.messageText) {
|
||||
actions.addTopic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<AddTopicWrapper>
|
||||
<div class="container noselect">
|
||||
<AddCarousel state={state} actions={actions} />
|
||||
<div class="input">
|
||||
<Input.TextArea placeholder="Message" autoSize={{ minRows: 2, maxRows: 6 }}
|
||||
<Input.TextArea placeholder="Message" autoSize={{ minRows: 2, maxRows: 6 }} onKeyPress={onKey}
|
||||
onChange={(e) => actions.setMessageText(e.target.value)} value={state.messageText} />
|
||||
</div>
|
||||
<div class="buttons">
|
||||
|
@ -64,6 +64,7 @@ export function useAddTopic() {
|
||||
else {
|
||||
await addChannelTopic(app.state.token, channel, message, []);
|
||||
}
|
||||
updateState({ messageText: null, messageColor: null, messageSize: null, backgroundColor: null });
|
||||
}
|
||||
catch(err) {
|
||||
window.alert(err);
|
||||
|
Loading…
Reference in New Issue
Block a user