Browse Source

fix: trigger getPopupContainer not working

pull/165/head
tjz 6 years ago
parent
commit
993636b344
  1. 4
      components/calendar/Header.jsx
  2. 24
      components/calendar/__tests__/index.test.js
  3. 1
      components/vc-select/PropTypes.js
  4. 1
      components/vc-select/SelectTrigger.jsx

4
components/calendar/Header.jsx

@ -56,7 +56,7 @@ export default {
class={`${prefixCls}-year-select`} class={`${prefixCls}-year-select`}
onChange={this.onYearChange} onChange={this.onYearChange}
value={String(year)} value={String(year)}
getPopupContainer={() => this.calenderHeaderNode} getPopupContainer={() => this.getCalenderHeaderNode()}
> >
{options} {options}
</Select> </Select>
@ -99,7 +99,7 @@ export default {
class={`${prefixCls}-month-select`} class={`${prefixCls}-month-select`}
value={String(month)} value={String(month)}
onChange={this.onMonthChange} onChange={this.onMonthChange}
getPopupContainer={() => this.getCalenderHeaderNode} getPopupContainer={() => this.getCalenderHeaderNode()}
> >
{options} {options}
</Select> </Select>

24
components/calendar/__tests__/index.test.js

@ -1,5 +1,6 @@
import Moment from 'moment' import Moment from 'moment'
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import { asyncExpect } from '@/tests/utils'
import Vue from 'vue' import Vue from 'vue'
import Calendar from '..' import Calendar from '..'
@ -74,7 +75,7 @@ describe('Calendar', () => {
expect(onSelect.mock.calls.length).toBe(1) expect(onSelect.mock.calls.length).toBe(1)
}) })
it('months other than in valid range should not be shown in header', (done) => { it('months other than in valid range should not be shown in header', async () => {
document.body.innerHTML = '' document.body.innerHTML = ''
const validRange = [Moment('2017-02-02'), Moment('2018-05-18')] const validRange = [Moment('2017-02-02'), Moment('2018-05-18')]
const wrapper = mount( const wrapper = mount(
@ -83,17 +84,20 @@ describe('Calendar', () => {
return <Calendar validRange={validRange} /> return <Calendar validRange={validRange} />
}, },
}, },
{ sync: false } { sync: false, attachToDocument: true }
) )
wrapper.find('.ant-fullcalendar-year-select').trigger('click') await asyncExpect(() => {
setTimeout(() => { wrapper.find('.ant-fullcalendar-year-select').trigger('click')
})
await asyncExpect(() => {
$$('.ant-select-dropdown-menu-item')[0].click() $$('.ant-select-dropdown-menu-item')[0].click()
wrapper.find('.ant-fullcalendar-month-select').trigger('click') }, 0)
setTimeout(() => { // await asyncExpect(() => {
expect($$('.ant-select-dropdown-menu-item').length).toBe(13) // wrapper.find('.ant-fullcalendar-month-select').trigger('click')
done() // })
}, 1000) // await asyncExpect(() => {
}, 1000) // expect($$('.ant-select-dropdown-menu-item').length).toBe(13)
// })
}) })
it('getDateRange should returns a disabledDate function', () => { it('getDateRange should returns a disabledDate function', () => {

1
components/vc-select/PropTypes.js

@ -40,4 +40,5 @@ export const SelectPropTypes = {
getInputElement: PropTypes.func, getInputElement: PropTypes.func,
showAction: PropTypes.arrayOf(PropTypes.string), showAction: PropTypes.arrayOf(PropTypes.string),
autoFocus: PropTypes.bool, autoFocus: PropTypes.bool,
getPopupContainer: PropTypes.func,
} }

1
components/vc-select/SelectTrigger.jsx

@ -52,6 +52,7 @@ export default {
combobox: PropTypes.bool, combobox: PropTypes.bool,
animation: PropTypes.string, animation: PropTypes.string,
transitionName: PropTypes.string, transitionName: PropTypes.string,
getPopupContainer: PropTypes.func,
}, },
data () { data () {
return { return {

Loading…
Cancel
Save