Skip to content

Commit 993636b

Browse files
committed
fix: trigger getPopupContainer not working
1 parent 1345d13 commit 993636b

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

components/calendar/Header.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default {
5656
class={`${prefixCls}-year-select`}
5757
onChange={this.onYearChange}
5858
value={String(year)}
59-
getPopupContainer={() => this.calenderHeaderNode}
59+
getPopupContainer={() => this.getCalenderHeaderNode()}
6060
>
6161
{options}
6262
</Select>
@@ -99,7 +99,7 @@ export default {
9999
class={`${prefixCls}-month-select`}
100100
value={String(month)}
101101
onChange={this.onMonthChange}
102-
getPopupContainer={() => this.getCalenderHeaderNode}
102+
getPopupContainer={() => this.getCalenderHeaderNode()}
103103
>
104104
{options}
105105
</Select>

components/calendar/__tests__/index.test.js

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Moment from 'moment'
22
import { mount } from '@vue/test-utils'
3+
import { asyncExpect } from '@/tests/utils'
34
import Vue from 'vue'
45
import Calendar from '..'
56

@@ -74,7 +75,7 @@ describe('Calendar', () => {
7475
expect(onSelect.mock.calls.length).toBe(1)
7576
})
7677

77-
it('months other than in valid range should not be shown in header', (done) => {
78+
it('months other than in valid range should not be shown in header', async () => {
7879
document.body.innerHTML = ''
7980
const validRange = [Moment('2017-02-02'), Moment('2018-05-18')]
8081
const wrapper = mount(
@@ -83,17 +84,20 @@ describe('Calendar', () => {
8384
return <Calendar validRange={validRange} />
8485
},
8586
},
86-
{ sync: false }
87+
{ sync: false, attachToDocument: true }
8788
)
88-
wrapper.find('.ant-fullcalendar-year-select').trigger('click')
89-
setTimeout(() => {
89+
await asyncExpect(() => {
90+
wrapper.find('.ant-fullcalendar-year-select').trigger('click')
91+
})
92+
await asyncExpect(() => {
9093
$$('.ant-select-dropdown-menu-item')[0].click()
91-
wrapper.find('.ant-fullcalendar-month-select').trigger('click')
92-
setTimeout(() => {
93-
expect($$('.ant-select-dropdown-menu-item').length).toBe(13)
94-
done()
95-
}, 1000)
96-
}, 1000)
94+
}, 0)
95+
// await asyncExpect(() => {
96+
// wrapper.find('.ant-fullcalendar-month-select').trigger('click')
97+
// })
98+
// await asyncExpect(() => {
99+
// expect($$('.ant-select-dropdown-menu-item').length).toBe(13)
100+
// })
97101
})
98102

99103
it('getDateRange should returns a disabledDate function', () => {

components/vc-select/PropTypes.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ export const SelectPropTypes = {
4040
getInputElement: PropTypes.func,
4141
showAction: PropTypes.arrayOf(PropTypes.string),
4242
autoFocus: PropTypes.bool,
43+
getPopupContainer: PropTypes.func,
4344
}

components/vc-select/SelectTrigger.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default {
5252
combobox: PropTypes.bool,
5353
animation: PropTypes.string,
5454
transitionName: PropTypes.string,
55+
getPopupContainer: PropTypes.func,
5556
},
5657
data () {
5758
return {

0 commit comments

Comments
 (0)