From 5491414d04610ab0d471613ab64fc994ab96d121 Mon Sep 17 00:00:00 2001 From: shenjunjian <40288193@qq.com> Date: Sun, 5 Jan 2025 22:57:35 -0800 Subject: [PATCH 1/3] fix(e2e): fix popper and select's e2e test --- .../pc/app/select/nest-grid-remote.spec.ts | 9 +++++---- packages/renderless/src/common/deps/popper.ts | 17 +++++++++-------- packages/renderless/src/select/index.ts | 6 ++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts b/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts index 077e523cc9..cfb03b078a 100644 --- a/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts +++ b/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts @@ -60,7 +60,8 @@ test.describe('下拉表格远程搜索', () => { await expect(input).toHaveValue('省 6-市 6') await input.click() await expect(page.getByRole('row', { name: '省份 6 城市 6 区域 6' })).toHaveClass(/row__current/) - await input.fill(' ') + // 由于修改示例,增加了空格。所以1个空格匹配全部行, 2个空格才空数据 + await input.fill(' ' + ' ') await input.press('Enter') await expect(dropdown).toBeVisible() await expect(dropdown.locator('.tiny-grid__body tbody')).toBeEmpty() @@ -79,12 +80,12 @@ test.describe('下拉表格远程搜索', () => { await expect(suffixSvg).toBeHidden() await expect(dropdown).toBeHidden() - await input.fill(' ') + await input.fill(' ' + ' ') await input.press('Enter') await page.waitForTimeout(1000) await expect(dropdown).toBeVisible() await expect(dropdown.locator('.tiny-grid__body tbody')).toBeEmpty() - await input.fill('') + await input.fill(' ') await input.press('Enter') await page.waitForTimeout(1000) await expect(dropdown.locator('.tiny-grid__body tbody')).not.toBeEmpty() @@ -127,7 +128,7 @@ test.describe('下拉表格远程搜索', () => { await tag.nth(0).locator('.tiny-svg').click() await tag.nth(0).locator('.tiny-svg').click() await expect((await tag.all()).length).toEqual(0) - await input.fill(' ') + await input.fill(' ' + ' ') await input.press('Enter') await expect(dropdown).toBeVisible() await expect(dropdown.locator('.tiny-grid__body tbody')).toBeEmpty() diff --git a/packages/renderless/src/common/deps/popper.ts b/packages/renderless/src/common/deps/popper.ts index 2ef2a57fd0..b8b0504e41 100644 --- a/packages/renderless/src/common/deps/popper.ts +++ b/packages/renderless/src/common/deps/popper.ts @@ -274,15 +274,16 @@ const stopFn = (ev: Event) => { } /** 全局的resize观察器, 监听popper的大小改变 */ -const resizeOb = isBrowser - ? new ResizeObserver((entries) => { - entries.forEach((entry) => { - if (entry.target.popperVm && entry.contentRect.height > 50) { - entry.target.popperVm.update() - } +const resizeOb = + isBrowser && typeof ResizeObserver === 'function' + ? new ResizeObserver((entries) => { + entries.forEach((entry) => { + if (entry.target.popperVm && entry.contentRect.height > 50) { + entry.target.popperVm.update() + } + }) }) - }) - : null + : null interface PopperOptions { arrowOffset: number diff --git a/packages/renderless/src/select/index.ts b/packages/renderless/src/select/index.ts index 670cc493c6..71ebcca92b 100644 --- a/packages/renderless/src/select/index.ts +++ b/packages/renderless/src/select/index.ts @@ -216,6 +216,12 @@ export const handleQueryChange = }) } + // 嵌套树时, filterMehod传递给tree组件,然后在上面: vm.$refs.selectTree.filter(value) 强制让tree去过滤了。 + // 如果不return,那么 api.defaultOnQueryChange 内部会再次过滤,而触发错误。 + if (props.renderType === constants.TYPE.Tree) { + return + } + state.triggerSearch = true api.defaultOnQueryChange(value, isInput) From 3a04d3bd430dde7efd20e2f1d75ca62535b522d9 Mon Sep 17 00:00:00 2001 From: shenjunjian <40288193@qq.com> Date: Sun, 5 Jan 2025 23:18:01 -0800 Subject: [PATCH 2/3] fix(e2e): fix --- packages/vue-common/src/breakpoint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vue-common/src/breakpoint.ts b/packages/vue-common/src/breakpoint.ts index 9350026a72..caece2c4cf 100644 --- a/packages/vue-common/src/breakpoint.ts +++ b/packages/vue-common/src/breakpoint.ts @@ -13,7 +13,7 @@ export const useBreakpoint = () => { const activeBreakpoint = hooks.ref('') const prefixes = ['2xl', 'xl', 'lg', 'md', 'sm'] const createMatchMedia = (mediaQueryString) => { - if (isServer) { + if (isServer && typeof matchMedia === 'function') { return { matches: false, media: mediaQueryString, From b94c3a58ea780de1cea7fd2dc37cb975877b7a23 Mon Sep 17 00:00:00 2001 From: shenjunjian <40288193@qq.com> Date: Sun, 5 Jan 2025 23:24:25 -0800 Subject: [PATCH 3/3] fix(e2e): fix --- packages/vue-common/src/breakpoint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vue-common/src/breakpoint.ts b/packages/vue-common/src/breakpoint.ts index caece2c4cf..e7994a7ce0 100644 --- a/packages/vue-common/src/breakpoint.ts +++ b/packages/vue-common/src/breakpoint.ts @@ -13,7 +13,7 @@ export const useBreakpoint = () => { const activeBreakpoint = hooks.ref('') const prefixes = ['2xl', 'xl', 'lg', 'md', 'sm'] const createMatchMedia = (mediaQueryString) => { - if (isServer && typeof matchMedia === 'function') { + if (isServer || typeof matchMedia !== 'function') { return { matches: false, media: mediaQueryString,