fix: Reject keyboard shortcut listeners if input box is active (#3019)

Reject keyboard shortcut listeners if input box is active
This commit is contained in:
Pranav Raj S 2021-09-15 20:15:06 +05:30 committed by GitHub
parent a14f4ede87
commit 3abcadb5cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 37 deletions

View file

@ -76,7 +76,6 @@
import { mapGetters } from 'vuex';
import { mixin as clickaway } from 'vue-clickaway';
import alertMixin from 'shared/mixins/alertMixin';
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
import EmojiInput from 'shared/components/emoji/EmojiInput';
import CannedResponse from './CannedResponse';
@ -108,13 +107,7 @@ export default {
ReplyBottomPanel,
WootMessageEditor,
},
mixins: [
clickaway,
inboxMixin,
uiSettingsMixin,
alertMixin,
eventListenerMixins,
],
mixins: [clickaway, inboxMixin, uiSettingsMixin, alertMixin],
props: {
selectedTweet: {
type: [Object, String],
@ -304,6 +297,15 @@ export default {
}
},
},
mounted() {
// Donot use the keyboard listener mixin here as the events here are supposed to be
// working even if input/textarea is focussed.
document.addEventListener('keydown', this.handleKeyEvents);
},
destroyed() {
document.removeEventListener('keydown', this.handleKeyEvents);
},
methods: {
toggleUserMention(currentMentionState) {
this.hasUserMention = currentMentionState;