diff --git a/docs/en-US/component/cascader.md b/docs/en-US/component/cascader.md index c40a7bd935..e86dfe99e9 100644 --- a/docs/en-US/component/cascader.md +++ b/docs/en-US/component/cascader.md @@ -209,9 +209,10 @@ cascader/panel ### CascaderPanel Slots -| Name | Description | Scope | -| ------- | ---------------------------------------------------------------------------------------------- | ----------------------------------- | -| default | the custom content of cascader node, which are current Node object and node data respectively. | ^[object]`{ node: any, data: any }` | +| Name | Description | Scope | +| -------------- | ---------------------------------------------------------------------------------------------- | ----------------------------------- | +| default | the custom content of cascader node, which are current Node object and node data respectively. | ^[object]`{ node: any, data: any }` | +| empty ^(2.8.3) | the content of the panel when there is no data. | — | ### CascaderPanel Exposes diff --git a/packages/components/cascader-panel/src/index.vue b/packages/components/cascader-panel/src/index.vue index 74a8484125..7b852cd647 100644 --- a/packages/components/cascader-panel/src/index.vue +++ b/packages/components/cascader-panel/src/index.vue @@ -9,7 +9,11 @@ :ref="(item) => (menuList[index] = item)" :index="index" :nodes="[...menu]" - /> + > + + diff --git a/packages/components/cascader-panel/src/menu.vue b/packages/components/cascader-panel/src/menu.vue index 92f18aedb3..697405e7cc 100644 --- a/packages/components/cascader-panel/src/menu.vue +++ b/packages/components/cascader-panel/src/menu.vue @@ -23,7 +23,7 @@ {{ t('el.cascader.loading') }}
- {{ t('el.cascader.noData') }} + {{ t('el.cascader.noData') }}
{ expect(inputEl.style.height).toEqual(`${sizeMap[size] - 2}px`) } }) + + describe('render empty slot', () => { + it('correct render panel empty slot', async () => { + const wrapper = _mount(() => ( + + {{ + empty: () =>
-=-empty-=-
, + }} + + )) + + await wrapper.find(TRIGGER).trigger('click') + const emptySlotEl = document.querySelector( + '.el-cascader-menu__empty-text' + ) + expect(emptySlotEl?.textContent).toBe('-=-empty-=-') + }) + + it('correct render menu list empty slot', async () => { + const wrapper = _mount(() => ( + + {{ + empty: () =>
-=-empty-=-no-data
, + }} +
+ )) + + const input = wrapper.find('input') + await input.trigger('focus') + const emptySlotEl = document.querySelector( + '.el-cascader-menu__empty-text' + ) + expect(emptySlotEl?.textContent).toBe('-=-empty-=-no-data') + }) + }) }) diff --git a/packages/components/cascader/src/cascader.vue b/packages/components/cascader/src/cascader.vue index fae02cd969..3a9fb25c46 100644 --- a/packages/components/cascader/src/cascader.vue +++ b/packages/components/cascader/src/cascader.vue @@ -152,7 +152,11 @@ :render-label="$slots.default" @expand-change="handleExpandChange" @close="$nextTick(() => togglePopperVisible(false))" - /> + > + +