Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/api/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,20 @@ resetOnOptionsChange: {
},
```

## retainTextOnClick

When true, the selected option text will not clear when the user clicks on the component. The search text will automatically be selected.

```js
/**
* Whether to retain the text in the search input when the user
* clicks on the dropdown.
*/
retainTextOnClick: {
type: Boolean,
default: false,
}
```

## searchable

Expand Down
16 changes: 16 additions & 0 deletions src/components/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,14 @@ export default {
type: [String, Number],
default: () => uniqueId(),
},
/**
* Whether to retain the text in the search input when the user
* clicks on the dropdown.
*/
retainTextOnClick: {
type: Boolean,
default: false,
}
},

data() {
Expand Down Expand Up @@ -1113,6 +1121,14 @@ export default {
} else if (!this.disabled) {
this.open = true
this.searchEl.focus()
if (this.value !== null && this.retainTextOnClick) {
this.search = this.getOptionLabel(this.value)
/**
* 0-second setTimeout to force this event to the end of the callback queue and
* ensure that the select event is called last.
*/
setTimeout(() => this.searchEl.select(), 0)
}
}
},

Expand Down