diff --git a/components/auto-complete/index.jsx b/components/auto-complete/index.jsx index c29604550..f164c74b9 100644 --- a/components/auto-complete/index.jsx +++ b/components/auto-complete/index.jsx @@ -55,7 +55,15 @@ const AutoComplete = { prop: 'value', event: 'change', }, + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, getInputElement() { const { $slots } = this; const children = filterEmpty($slots.default); diff --git a/components/cascader/index.jsx b/components/cascader/index.jsx index e43fd2209..dbb2290f4 100644 --- a/components/cascader/index.jsx +++ b/components/cascader/index.jsx @@ -141,6 +141,11 @@ const Cascader = { prop: 'value', event: 'change', }, + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, inject: { configProvider: { default: () => ({}) }, localeData: { default: () => ({}) }, @@ -177,6 +182,9 @@ const Cascader = { }, }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, highlightKeyword(str, keyword, prefixCls) { return str .split(keyword) diff --git a/components/date-picker/wrapPicker.js b/components/date-picker/wrapPicker.js index dd47d7e69..310466ef0 100644 --- a/components/date-picker/wrapPicker.js +++ b/components/date-picker/wrapPicker.js @@ -37,7 +37,11 @@ export default function wrapPicker(Picker, props, defaultFormat) { prop: 'value', event: 'change', }, - + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, mounted() { const { autoFocus, disabled } = this; if (autoFocus && !disabled) { @@ -47,6 +51,9 @@ export default function wrapPicker(Picker, props, defaultFormat) { } }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, handleOpenChange(open) { this.$emit('openChange', open); }, diff --git a/components/dropdown/dropdown-button.jsx b/components/dropdown/dropdown-button.jsx index 375a55707..bfd3ffc13 100644 --- a/components/dropdown/dropdown-button.jsx +++ b/components/dropdown/dropdown-button.jsx @@ -25,7 +25,18 @@ export default { event: 'visibleChange', }, props: DropdownButtonProps, + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, + inject: { + configProvider: { default: () => ({}) }, + }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, onClick(e) { this.$emit('click', e); }, @@ -33,9 +44,6 @@ export default { this.$emit('visibleChange', val); }, }, - inject: { - configProvider: { default: () => ({}) }, - }, render() { const { type, diff --git a/components/dropdown/dropdown.jsx b/components/dropdown/dropdown.jsx index 942d5c54c..fa6945b99 100644 --- a/components/dropdown/dropdown.jsx +++ b/components/dropdown/dropdown.jsx @@ -20,10 +20,18 @@ const Dropdown = { prop: 'visible', event: 'visibleChange', }, + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, inject: { configProvider: { default: () => ({}) }, }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, getTransitionName() { const { placement = '', transitionName } = this.$props; if (transitionName !== undefined) { diff --git a/components/select/index.jsx b/components/select/index.jsx index 4a29a3519..25ac1adab 100644 --- a/components/select/index.jsx +++ b/components/select/index.jsx @@ -106,6 +106,11 @@ const Select = { prop: 'value', event: 'change', }, + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, inject: { configProvider: { default: () => ({}) }, }, @@ -118,6 +123,9 @@ const Select = { ); }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, focus() { this.$refs.vcSelect.focus(); }, diff --git a/components/time-picker/index.jsx b/components/time-picker/index.jsx index 5787f6c67..686297c4d 100644 --- a/components/time-picker/index.jsx +++ b/components/time-picker/index.jsx @@ -86,6 +86,11 @@ const TimePicker = { prop: 'value', event: 'change', }, + provide() { + return { + savePopupRef: this.savePopupRef, + }; + }, inject: { configProvider: { default: () => ({}) }, }, @@ -104,6 +109,9 @@ const TimePicker = { }, }, methods: { + savePopupRef(ref) { + this.popupRef = ref; + }, handleChange(value) { if (!hasProp(this, 'value')) { this.setState({ sValue: value }); diff --git a/components/vc-trigger/Trigger.jsx b/components/vc-trigger/Trigger.jsx index d8038a66a..12901c9d9 100644 --- a/components/vc-trigger/Trigger.jsx +++ b/components/vc-trigger/Trigger.jsx @@ -77,6 +77,7 @@ export default { }, inject: { vcTriggerContext: { default: () => ({}) }, + savePopupRef: { default: () => noop }, }, data() { const props = this.$props; @@ -350,6 +351,7 @@ export default { }, savePopup(node) { this._component = node; + this.savePopupRef(node); }, getComponent() { const self = this;