From 5468309f6aefbc61467338d2a96f29d6c416cc54 Mon Sep 17 00:00:00 2001 From: tusooa Date: Mon, 20 Feb 2023 23:49:34 -0500 Subject: [PATCH] Make it possible to auto-select the first candidate in autocomplete --- src/components/emoji_input/emoji_input.js | 5 ++++- src/components/settings_modal/tabs/general_tab.vue | 8 ++++++++ src/i18n/en.json | 1 + src/modules/config.js | 3 ++- src/modules/instance.js | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js index 8a8d098d07..68654f6932 100644 --- a/src/components/emoji_input/emoji_input.js +++ b/src/components/emoji_input/emoji_input.js @@ -134,6 +134,9 @@ const EmojiInput = { padEmoji () { return this.$store.getters.mergedConfig.padEmoji }, + defaultCandidateIndex () { + return this.$store.getters.mergedConfig.autocompleteSelect ? 0 : -1 + }, preText () { return this.modelValue.slice(0, this.caret) }, @@ -287,7 +290,7 @@ const EmojiInput = { ...rest, img: imageUrl || '' })) - this.highlighted = -1 + this.highlighted = this.defaultCandidateIndex this.$refs.screenReaderNotice.announce( this.$tc('tool_tip.autocomplete_available', this.suggestions.length, diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 703e94a0f5..65248ac1ba 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -501,6 +501,14 @@ {{ $t('settings.pad_emoji') }} +
  • + + {{ $t('settings.autocomplete_select_first') }} + +
  • diff --git a/src/i18n/en.json b/src/i18n/en.json index dba8a13f73..6c9bc8e261 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -465,6 +465,7 @@ "domain_mutes": "Domains", "avatar_size_instruction": "The recommended minimum size for avatar images is 150x150 pixels.", "pad_emoji": "Pad emoji with spaces when adding from picker", + "autocomplete_select_first": "Automatically select the first candidate when autocomplete results are available", "emoji_reactions_on_timeline": "Show emoji reactions on timeline", "export_theme": "Save preset", "filtering": "Filtering", diff --git a/src/modules/config.js b/src/modules/config.js index eb33f95f9c..3d9cf59140 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -115,7 +115,8 @@ export const defaultState = { conversationTreeAdvanced: undefined, // instance default conversationOtherRepliesButton: undefined, // instance default conversationTreeFadeAncestors: undefined, // instance default - maxDepthInThread: undefined // instance default + maxDepthInThread: undefined, // instance default + autocompleteSelect: undefined // instance default } // caching the instance default properties diff --git a/src/modules/instance.js b/src/modules/instance.js index 16f7258312..938ca64df3 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -104,6 +104,7 @@ const defaultState = { conversationOtherRepliesButton: 'below', conversationTreeFadeAncestors: false, maxDepthInThread: 6, + autocompleteSelect: false, // Nasty stuff customEmoji: [],