From 7a0a36499d61d1297021e1d89b17fcfc5483caf0 Mon Sep 17 00:00:00 2001 From: tjz <415800467@qq.com> Date: Tue, 27 Feb 2018 21:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/select/demo/size.md | 4 ++++ components/select/style/index.less | 2 +- components/vc-menu/MenuMixin.js | 4 +++- components/vc-select/DropdownMenu.vue | 9 ++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/components/select/demo/size.md b/components/select/demo/size.md index 3a0b30aa6..295e1ca91 100644 --- a/components/select/demo/size.md +++ b/components/select/demo/size.md @@ -48,6 +48,7 @@ The height of the input field for the select defaults to 32px. If size is set to :defaultValue="['a1', 'b2']" style="width: 200px" @change="handleChange" + @popupScroll="popupScroll" > {{(i + 9).toString(36) + i}} @@ -78,6 +79,9 @@ export default { methods: { handleChange(value) { console.log(`Selected: ${value}`); + }, + popupScroll(){ + console.log('popupScroll') } } } diff --git a/components/select/style/index.less b/components/select/style/index.less index 64b954371..28d2e45eb 100644 --- a/components/select/style/index.less +++ b/components/select/style/index.less @@ -453,7 +453,7 @@ padding-left: 0; // Override default ul/ol list-style: none; max-height: 250px; - // overflow: auto; + overflow: auto; &-item-group-list { margin: 0; diff --git a/components/vc-menu/MenuMixin.js b/components/vc-menu/MenuMixin.js index c71b05391..c3dcaac58 100644 --- a/components/vc-menu/MenuMixin.js +++ b/components/vc-menu/MenuMixin.js @@ -197,7 +197,9 @@ export default { // visible: props.visible, }, class: className, - on: {}, + on: { + ...this.$listeners, + }, } if (props.id) { domProps.id = props.id diff --git a/components/vc-select/DropdownMenu.vue b/components/vc-select/DropdownMenu.vue index 2d3d9945c..c5579f7d9 100644 --- a/components/vc-select/DropdownMenu.vue +++ b/components/vc-select/DropdownMenu.vue @@ -38,7 +38,7 @@ export default { watch: { visible (val) { if (!val) { - this.lastVisible = false + this.lastVisible = val } }, }, @@ -51,6 +51,7 @@ export default { } this.lastVisible = props.visible this.lastInputValue = props.inputValue + this.prevVisible = this.visible }, methods: { scrollActiveItemToView () { @@ -89,7 +90,7 @@ export default { firstActiveValue, dropdownMenuStyle, } = props - const { menuDeselect, menuSelect } = this.$listeners + const { menuDeselect, menuSelect, popupScroll } = this.$listeners if (menuItems && menuItems.length) { const selectedKeys = getSelectKeys(menuItems, value) const menuProps = { @@ -103,6 +104,9 @@ export default { style: dropdownMenuStyle, ref: 'menuRef', } + if (popupScroll) { + menuProps.on.scroll = popupScroll + } if (multiple) { menuProps.on.deselect = menuDeselect menuProps.on.select = menuSelect @@ -160,7 +164,6 @@ export default { }, render () { const renderMenu = this.renderMenu() - this.prevVisible = this.visible const { popupFocus, popupScroll } = this.$listeners return renderMenu ? (