diff --git a/packages/date-picker/__tests__/date-picker.spec.ts b/packages/date-picker/__tests__/date-picker.spec.ts
index 499e5009b9..8b307d1d1a 100644
--- a/packages/date-picker/__tests__/date-picker.spec.ts
+++ b/packages/date-picker/__tests__/date-picker.spec.ts
@@ -1,4 +1,4 @@
-import Picker from '@element-plus/time-picker/src/common/picker.vue'
+import { CommonPicker } from '@element-plus/time-picker'
import { mount } from '@vue/test-utils'
import dayjs from 'dayjs'
import { nextTick } from 'vue'
@@ -22,19 +22,26 @@ afterEach(() => {
describe('DatePicker', () => {
it('create & custom class & style', async () => {
+ const popperClassName = 'popper-class-test'
+ const customClassName = 'custom-class-test'
const wrapper = _mount(``)
+ :class="customClassName"
+ :popperClass="popperClassName"
+ />`, () => ({ popperClassName, customClassName }))
const input = wrapper.find('input')
expect(input.attributes('placeholder')).toBe('test_')
expect(input.attributes('readonly')).not.toBeUndefined()
const outterInput = wrapper.find('.el-input')
- expect(outterInput.classes()).toContain('customClass')
+ expect(outterInput.classes()).toContain(customClassName)
expect(outterInput.attributes().style).toBeDefined()
+ input.trigger('blur')
+ input.trigger('focus')
+ await nextTick()
+ expect(document.querySelector('.el-picker__popper').classList.contains(popperClassName)).toBe(true)
})
it('select date', async () => {
@@ -87,10 +94,10 @@ describe('DatePicker', () => {
expect(vm.value.getHours()).toBe(12)
expect(vm.value.getMinutes()).toBe(0)
expect(vm.value.getSeconds()).toBe(1)
- const picker = wrapper.findComponent(Picker);
+ const picker = wrapper.findComponent(CommonPicker);
(picker.vm as any).showClose = true
await nextTick();
- (picker.element.querySelector('.el-icon-circle-close') as HTMLElement).click()
+ (document.querySelector('.el-icon-circle-close') as HTMLElement).click()
expect(vm.value).toBeNull()
})
diff --git a/packages/date-picker/src/date-picker-com/panel-date-range.vue b/packages/date-picker/src/date-picker-com/panel-date-range.vue
index 75ae355351..d07034050e 100644
--- a/packages/date-picker/src/date-picker-com/panel-date-range.vue
+++ b/packages/date-picker/src/date-picker-com/panel-date-range.vue
@@ -579,6 +579,7 @@ export default defineComponent({
// pickerBase.hub.emit('SetPickerOption', ['isValidValue', isValidValue])
ctx.emit('set-picker-option', ['formatToString', formatToString])
+ ctx.emit('set-picker-option', ['handleClear', handleClear])
const pickerBase = inject('EP_PICKER_BASE') as any
const { shortcuts, disabledDate, cellClassName, format, defaultTime, defaultValue, arrowControl } = pickerBase.props
diff --git a/packages/time-picker/src/common/picker.vue b/packages/time-picker/src/common/picker.vue
index ecc7280d8b..ae7fa4a968 100644
--- a/packages/time-picker/src/common/picker.vue
+++ b/packages/time-picker/src/common/picker.vue
@@ -1,7 +1,4 @@
-
-
-
{
diff --git a/packages/time-picker/src/common/props.ts b/packages/time-picker/src/common/props.ts
index ba0fe1803c..ea81b1d73e 100644
--- a/packages/time-picker/src/common/props.ts
+++ b/packages/time-picker/src/common/props.ts
@@ -5,6 +5,10 @@ export const defaultProps = {
type: [Array, String],
default: '',
},
+ popperClass: {
+ type: String,
+ default: '',
+ },
format: {
type: String,
},