mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
refactor(select-menu): auto pending on selected option
This commit is contained in:
parent
5ad00e793b
commit
71cb2dda21
@ -140,7 +140,7 @@ export default {
|
||||
type: [Number, String],
|
||||
default: undefined
|
||||
},
|
||||
autoPendingFirstOption: {
|
||||
autoPending: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
@ -162,8 +162,10 @@ export default {
|
||||
const virtualListRef = ref(null)
|
||||
const scrollbarRef = ref(null)
|
||||
const pendingNodeRef = ref(
|
||||
props.autoPendingFirstOption
|
||||
? props.treeMate.getFirstAvailableNode()
|
||||
props.autoPending
|
||||
? props.value === null
|
||||
? props.treeMate.getFirstAvailableNode()
|
||||
: props.treeMate.getNode(props.value)
|
||||
: null
|
||||
)
|
||||
onMounted(() => {
|
||||
@ -215,7 +217,7 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
treeMate (value) {
|
||||
if (this.autoPendingFirstOption) {
|
||||
if (this.autoPending) {
|
||||
const tmNode = this.treeMate.getFirstAvailableNode()
|
||||
this.setPendingTmNode(tmNode)
|
||||
} else {
|
||||
|
@ -53,7 +53,7 @@
|
||||
v-if="active"
|
||||
ref="menu"
|
||||
v-clickoutside="handleClickOutsideMenu"
|
||||
auto-pending-first-option
|
||||
auto-pending
|
||||
class="n-auto-complete-menu"
|
||||
:theme="mergedTheme"
|
||||
:pattern="value"
|
||||
|
@ -14,7 +14,7 @@
|
||||
ref="menuRef"
|
||||
v-clickoutside="handleClickOutside"
|
||||
class="n-cascader-menu"
|
||||
auto-pending-first-option
|
||||
auto-pending
|
||||
:theme="theme"
|
||||
:pattern="pattern"
|
||||
:tree-mate="selectTreeMate"
|
||||
|
@ -68,7 +68,7 @@
|
||||
ref="menuRef"
|
||||
v-clickoutside="handleMenuClickOutside"
|
||||
class="n-select-menu"
|
||||
auto-pending-first-option
|
||||
auto-pending
|
||||
:theme="mergedTheme"
|
||||
:pattern="pattern"
|
||||
:tree-mate="treeMate"
|
||||
|
Loading…
Reference in New Issue
Block a user