From ba73c090b2987cc4682600d0f9905687da8a7e9a Mon Sep 17 00:00:00 2001 From: Johan Bisse Mattsson Date: Tue, 19 Nov 2024 13:35:22 +0100 Subject: [PATCH] fix(supersearch): Remove redundant text-selection code If the expanded search text box is placed at the same place as the collapsed, text-selection by double-clicking and triple-clicking will work mostly natively out-of-the-box. If we decide that we need to support cases where the expanded search text box is placed somewhere else then https://github.com/libris/lxlviewer/pull/1171 can be merged. --- packages/supersearch/e2e/supersearch.spec.ts | 5 ----- .../supersearch/src/lib/components/SuperSearch.svelte | 8 +++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/supersearch/e2e/supersearch.spec.ts b/packages/supersearch/e2e/supersearch.spec.ts index b9ec12221..d83eb2a6b 100644 --- a/packages/supersearch/e2e/supersearch.spec.ts +++ b/packages/supersearch/e2e/supersearch.spec.ts @@ -67,9 +67,4 @@ test('syncs collapsed and expanded editor views', async ({ page }) => { await page.evaluate(() => window.getSelection()?.toString()), 'text selection should be synced' ).toBe('Hello world'); - await page.locator('[data-test-id="test1"]').getByRole('textbox').locator('div').dblclick(); - expect( - await page.evaluate(() => window.getSelection()?.toString()), - 'collapsed editor view allows double-clicking to select words' - ).toBe('world'); }); diff --git a/packages/supersearch/src/lib/components/SuperSearch.svelte b/packages/supersearch/src/lib/components/SuperSearch.svelte index bc8206315..997d30f65 100644 --- a/packages/supersearch/src/lib/components/SuperSearch.svelte +++ b/packages/supersearch/src/lib/components/SuperSearch.svelte @@ -30,10 +30,8 @@ placeholderCompartment.of(placeholderExtension(placeholder)) ]; - function handleClickCollapsedEditorView() { - setTimeout(() => { - if (!dialog?.open) showExpandedSearch(); // use timeout to allow word-selection by double-clicking - }, 200); + function handleClickCollapsed() { + if (!dialog?.open) showExpandedSearch(); } function handleChangeCodeMirror(event: ChangeCodeMirrorEvent) { @@ -81,7 +79,7 @@