Skip to content

Commit

Permalink
feat: add popup ref
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jul 4, 2019
1 parent 0d67fc1 commit f9373e4
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 4 deletions.
8 changes: 8 additions & 0 deletions components/auto-complete/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions components/cascader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ const Cascader = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
localeData: { default: () => ({}) },
Expand Down Expand Up @@ -177,6 +182,9 @@ const Cascader = {
},
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
highlightKeyword(str, keyword, prefixCls) {
return str
.split(keyword)
Expand Down
9 changes: 8 additions & 1 deletion components/date-picker/wrapPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -47,6 +51,9 @@ export default function wrapPicker(Picker, props, defaultFormat) {
}
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
handleOpenChange(open) {
this.$emit('openChange', open);
},
Expand Down
14 changes: 11 additions & 3 deletions components/dropdown/dropdown-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,25 @@ 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);
},
onVisibleChange(val) {
this.$emit('visibleChange', val);
},
},
inject: {
configProvider: { default: () => ({}) },
},
render() {
const {
type,
Expand Down
8 changes: 8 additions & 0 deletions components/dropdown/dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions components/select/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ const Select = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
},
Expand All @@ -118,6 +123,9 @@ const Select = {
);
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
focus() {
this.$refs.vcSelect.focus();
},
Expand Down
8 changes: 8 additions & 0 deletions components/time-picker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const TimePicker = {
prop: 'value',
event: 'change',
},
provide() {
return {
savePopupRef: this.savePopupRef,
};
},
inject: {
configProvider: { default: () => ({}) },
},
Expand All @@ -104,6 +109,9 @@ const TimePicker = {
},
},
methods: {
savePopupRef(ref) {
this.popupRef = ref;
},
handleChange(value) {
if (!hasProp(this, 'value')) {
this.setState({ sValue: value });
Expand Down
2 changes: 2 additions & 0 deletions components/vc-trigger/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default {
},
inject: {
vcTriggerContext: { default: () => ({}) },
savePopupRef: { default: () => noop },
},
data() {
const props = this.$props;
Expand Down Expand Up @@ -350,6 +351,7 @@ export default {
},
savePopup(node) {
this._component = node;
this.savePopupRef(node);
},
getComponent() {
const self = this;
Expand Down

0 comments on commit f9373e4

Please sign in to comment.