Select search text on focus (#1201)

This commit is contained in:
Svallinn 2021-04-15 19:30:26 +00:00 committed by GitHub
parent ebc829cef0
commit 1fd08af136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -27,6 +27,10 @@ export default Vue.extend({
type: Boolean, type: Boolean,
default: false default: false
}, },
selectOnFocus: {
type: Boolean,
default: false
},
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
@ -130,6 +134,13 @@ export default Vue.extend({
handleInputBlur: function () { handleInputBlur: function () {
if (!this.searchState.isPointerInList) { this.searchState.showOptions = false } if (!this.searchState.isPointerInList) { this.searchState.showOptions = false }
},
handleFocus: function(e) {
this.searchState.showOptions = true
if (this.selectOnFocus) {
e.target.select()
}
} }
} }
}) })

View File

@ -27,7 +27,7 @@
:placeholder="placeholder" :placeholder="placeholder"
:disabled="disabled" :disabled="disabled"
@input="e => handleInput(e.target.value)" @input="e => handleInput(e.target.value)"
@focus="searchState.showOptions = true" @focus="handleFocus"
@blur="handleInputBlur" @blur="handleInputBlur"
@keydown="e => handleKeyDown(e.keyCode)" @keydown="e => handleKeyDown(e.keyCode)"
> >

View File

@ -44,6 +44,7 @@
:placeholder="$t('Search / Go to URL')" :placeholder="$t('Search / Go to URL')"
class="searchInput" class="searchInput"
:is-search="true" :is-search="true"
:select-on-focus="true"
:data-list="searchSuggestionsDataList" :data-list="searchSuggestionsDataList"
@input="getSearchSuggestionsDebounce" @input="getSearchSuggestionsDebounce"
@click="goToSearch" @click="goToSearch"

View File

@ -70,6 +70,7 @@
</div> </div>
<ft-input <ft-input
:placeholder="$t('Channel.Search Channel')" :placeholder="$t('Channel.Search Channel')"
:select-on-focus="true"
class="channelSearch" class="channelSearch"
@click="newSearch" @click="newSearch"
/> />