Skip to content

Commit f9373e4

Browse files
committed
feat: add popup ref
1 parent 0d67fc1 commit f9373e4

File tree

8 files changed

+61
-4
lines changed

8 files changed

+61
-4
lines changed

components/auto-complete/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ const AutoComplete = {
5555
prop: 'value',
5656
event: 'change',
5757
},
58+
provide() {
59+
return {
60+
savePopupRef: this.savePopupRef,
61+
};
62+
},
5863
methods: {
64+
savePopupRef(ref) {
65+
this.popupRef = ref;
66+
},
5967
getInputElement() {
6068
const { $slots } = this;
6169
const children = filterEmpty($slots.default);

components/cascader/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ const Cascader = {
141141
prop: 'value',
142142
event: 'change',
143143
},
144+
provide() {
145+
return {
146+
savePopupRef: this.savePopupRef,
147+
};
148+
},
144149
inject: {
145150
configProvider: { default: () => ({}) },
146151
localeData: { default: () => ({}) },
@@ -177,6 +182,9 @@ const Cascader = {
177182
},
178183
},
179184
methods: {
185+
savePopupRef(ref) {
186+
this.popupRef = ref;
187+
},
180188
highlightKeyword(str, keyword, prefixCls) {
181189
return str
182190
.split(keyword)

components/date-picker/wrapPicker.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export default function wrapPicker(Picker, props, defaultFormat) {
3737
prop: 'value',
3838
event: 'change',
3939
},
40-
40+
provide() {
41+
return {
42+
savePopupRef: this.savePopupRef,
43+
};
44+
},
4145
mounted() {
4246
const { autoFocus, disabled } = this;
4347
if (autoFocus && !disabled) {
@@ -47,6 +51,9 @@ export default function wrapPicker(Picker, props, defaultFormat) {
4751
}
4852
},
4953
methods: {
54+
savePopupRef(ref) {
55+
this.popupRef = ref;
56+
},
5057
handleOpenChange(open) {
5158
this.$emit('openChange', open);
5259
},

components/dropdown/dropdown-button.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,25 @@ export default {
2525
event: 'visibleChange',
2626
},
2727
props: DropdownButtonProps,
28+
provide() {
29+
return {
30+
savePopupRef: this.savePopupRef,
31+
};
32+
},
33+
inject: {
34+
configProvider: { default: () => ({}) },
35+
},
2836
methods: {
37+
savePopupRef(ref) {
38+
this.popupRef = ref;
39+
},
2940
onClick(e) {
3041
this.$emit('click', e);
3142
},
3243
onVisibleChange(val) {
3344
this.$emit('visibleChange', val);
3445
},
3546
},
36-
inject: {
37-
configProvider: { default: () => ({}) },
38-
},
3947
render() {
4048
const {
4149
type,

components/dropdown/dropdown.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ const Dropdown = {
2020
prop: 'visible',
2121
event: 'visibleChange',
2222
},
23+
provide() {
24+
return {
25+
savePopupRef: this.savePopupRef,
26+
};
27+
},
2328
inject: {
2429
configProvider: { default: () => ({}) },
2530
},
2631
methods: {
32+
savePopupRef(ref) {
33+
this.popupRef = ref;
34+
},
2735
getTransitionName() {
2836
const { placement = '', transitionName } = this.$props;
2937
if (transitionName !== undefined) {

components/select/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ const Select = {
106106
prop: 'value',
107107
event: 'change',
108108
},
109+
provide() {
110+
return {
111+
savePopupRef: this.savePopupRef,
112+
};
113+
},
109114
inject: {
110115
configProvider: { default: () => ({}) },
111116
},
@@ -118,6 +123,9 @@ const Select = {
118123
);
119124
},
120125
methods: {
126+
savePopupRef(ref) {
127+
this.popupRef = ref;
128+
},
121129
focus() {
122130
this.$refs.vcSelect.focus();
123131
},

components/time-picker/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ const TimePicker = {
8686
prop: 'value',
8787
event: 'change',
8888
},
89+
provide() {
90+
return {
91+
savePopupRef: this.savePopupRef,
92+
};
93+
},
8994
inject: {
9095
configProvider: { default: () => ({}) },
9196
},
@@ -104,6 +109,9 @@ const TimePicker = {
104109
},
105110
},
106111
methods: {
112+
savePopupRef(ref) {
113+
this.popupRef = ref;
114+
},
107115
handleChange(value) {
108116
if (!hasProp(this, 'value')) {
109117
this.setState({ sValue: value });

components/vc-trigger/Trigger.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export default {
7777
},
7878
inject: {
7979
vcTriggerContext: { default: () => ({}) },
80+
savePopupRef: { default: () => noop },
8081
},
8182
data() {
8283
const props = this.$props;
@@ -350,6 +351,7 @@ export default {
350351
},
351352
savePopup(node) {
352353
this._component = node;
354+
this.savePopupRef(node);
353355
},
354356
getComponent() {
355357
const self = this;

0 commit comments

Comments
 (0)