feat: time-picker and tooltip support configProvider.getPopupContainer

pull/398/head
tangjinzhou 2019-01-07 20:53:42 +08:00
parent 06fe9ec935
commit b2d6577b76
3 changed files with 11 additions and 3 deletions

View File

@ -83,6 +83,9 @@ const TimePicker = {
prop: 'value',
event: 'change',
},
inject: {
configProvider: { default: {}},
},
data () {
const value = this.value || this.defaultValue
if (value && !interopDefault(moment).isMoment(value)) {
@ -147,7 +150,7 @@ const TimePicker = {
</div>
) : null
}
const { prefixCls } = props
const { prefixCls, getPopupContainer } = props
let suffixIcon = getComponentFromProp(this, 'suffixIcon')
suffixIcon = Array.isArray(suffixIcon) ? suffixIcon[0] : suffixIcon
const clockIcon = suffixIcon && (
@ -178,10 +181,12 @@ const TimePicker = {
theme='filled'
/>
)
const { getPopupContainer: getContextPopupContainer } = this.configProvider
const timeProps = {
props: {
...generateShowHourMinuteSecond(format),
...props,
getPopupContainer: getPopupContainer || getContextPopupContainer,
format,
value: this.sValue,
placeholder: props.placeholder === undefined ? locale.placeholder : props.placeholder,

View File

@ -28,6 +28,9 @@ export default {
prop: 'visible',
event: 'visibleChange',
},
inject: {
configProvider: { default: {}},
},
data () {
return {
sVisible: !!this.$props.visible,
@ -139,6 +142,7 @@ export default {
render (h) {
const { $props, $data, $slots, $listeners } = this
const { prefixCls, openClassName, getPopupContainer } = $props
const { getPopupContainer: getContextPopupContainer } = this.configProvider
let children = ($slots.default || []).filter(c => c.tag || c.text.trim() !== '')
children = children.length === 1 ? children[0] : children
let sVisible = $data.sVisible
@ -156,7 +160,7 @@ export default {
const tooltipProps = {
props: {
...$props,
getTooltipContainer: getPopupContainer,
getTooltipContainer: getPopupContainer || getContextPopupContainer,
builtinPlacements: this.getPlacements(),
visible: sVisible,
},

View File

@ -14,7 +14,6 @@ export default () => ({
prefixCls: PropTypes.string.def('ant-tooltip'),
mouseEnterDelay: PropTypes.number.def(0.1),
mouseLeaveDelay: PropTypes.number.def(0.1),
getTooltipContainer: PropTypes.func,
getPopupContainer: PropTypes.func,
arrowPointAtCenter: PropTypes.bool.def(false),
autoAdjustOverflow: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]).def(true),