Skip to content

Commit b2d6577

Browse files
committed
feat: time-picker and tooltip support configProvider.getPopupContainer
1 parent 06fe9ec commit b2d6577

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

components/time-picker/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const TimePicker = {
8383
prop: 'value',
8484
event: 'change',
8585
},
86+
inject: {
87+
configProvider: { default: {}},
88+
},
8689
data () {
8790
const value = this.value || this.defaultValue
8891
if (value && !interopDefault(moment).isMoment(value)) {
@@ -147,7 +150,7 @@ const TimePicker = {
147150
</div>
148151
) : null
149152
}
150-
const { prefixCls } = props
153+
const { prefixCls, getPopupContainer } = props
151154
let suffixIcon = getComponentFromProp(this, 'suffixIcon')
152155
suffixIcon = Array.isArray(suffixIcon) ? suffixIcon[0] : suffixIcon
153156
const clockIcon = suffixIcon && (
@@ -178,10 +181,12 @@ const TimePicker = {
178181
theme='filled'
179182
/>
180183
)
184+
const { getPopupContainer: getContextPopupContainer } = this.configProvider
181185
const timeProps = {
182186
props: {
183187
...generateShowHourMinuteSecond(format),
184188
...props,
189+
getPopupContainer: getPopupContainer || getContextPopupContainer,
185190
format,
186191
value: this.sValue,
187192
placeholder: props.placeholder === undefined ? locale.placeholder : props.placeholder,

components/tooltip/Tooltip.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default {
2828
prop: 'visible',
2929
event: 'visibleChange',
3030
},
31+
inject: {
32+
configProvider: { default: {}},
33+
},
3134
data () {
3235
return {
3336
sVisible: !!this.$props.visible,
@@ -139,6 +142,7 @@ export default {
139142
render (h) {
140143
const { $props, $data, $slots, $listeners } = this
141144
const { prefixCls, openClassName, getPopupContainer } = $props
145+
const { getPopupContainer: getContextPopupContainer } = this.configProvider
142146
let children = ($slots.default || []).filter(c => c.tag || c.text.trim() !== '')
143147
children = children.length === 1 ? children[0] : children
144148
let sVisible = $data.sVisible
@@ -156,7 +160,7 @@ export default {
156160
const tooltipProps = {
157161
props: {
158162
...$props,
159-
getTooltipContainer: getPopupContainer,
163+
getTooltipContainer: getPopupContainer || getContextPopupContainer,
160164
builtinPlacements: this.getPlacements(),
161165
visible: sVisible,
162166
},

components/tooltip/abstractTooltipProps.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default () => ({
1414
prefixCls: PropTypes.string.def('ant-tooltip'),
1515
mouseEnterDelay: PropTypes.number.def(0.1),
1616
mouseLeaveDelay: PropTypes.number.def(0.1),
17-
getTooltipContainer: PropTypes.func,
1817
getPopupContainer: PropTypes.func,
1918
arrowPointAtCenter: PropTypes.bool.def(false),
2019
autoAdjustOverflow: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]).def(true),

0 commit comments

Comments
 (0)