refactor(select-menu): auto pending on selected option

This commit is contained in:
07akioni 2020-10-30 12:08:59 +08:00
parent 5ad00e793b
commit 71cb2dda21
4 changed files with 9 additions and 7 deletions

View File

@ -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.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 {

View File

@ -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"

View File

@ -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"

View File

@ -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"