Skip to content

Commit 3622e42

Browse files
fix(supersearch): fix cursor issues (#1654)
* Add draw, theme as supersearch extensions * Margin around atomic pills as inline css * CSS tweaks * Fixed flaky test, uncomment a11y test on help page
1 parent 451ac8b commit 3622e42

5 files changed

Lines changed: 39 additions & 10 deletions

File tree

‎lxl-web/src/lib/styles/lxlquery.css‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
color: var(--text-body);
33
font-size: var(--text-sm);
44
white-space: nowrap;
5-
6-
@media screen and (min-width: 640px) {
7-
font-size: var(--text-sm);
8-
}
95
}
106

117
.lxl-qualifier.editing {
@@ -49,10 +45,15 @@
4945
background-color: var(--color-accent-50);
5046
}
5147

52-
.lxl-qualifier-value:not(:has(.lxl-ghost-paren)) {
48+
/* make up space for missing parens */
49+
.lxl-qualifier-value.editable:not(:has(.lxl-ghost-paren)) {
5350
padding-inline: calc(var(--spacing) * 1.5);
5451
}
5552

53+
.lxl-qualifier-value.editable {
54+
margin-left: -2px;
55+
}
56+
5657
.atomic .lxl-qualifier-value {
5758
border-radius: 0;
5859
}

‎lxl-web/tests/help.filters.spec.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import { expect, test } from '@playwright/test';
2-
// import AxeBuilder from '@axe-core/playwright';
2+
import AxeBuilder from '@axe-core/playwright';
33

44
test.beforeEach(async ({ page }) => {
55
await page.goto('/help/filters');
66
});
77

8-
/*
98
test('should not have any detectable a11y issues', async ({ page }) => {
10-
const accessibilityScanResults = await new AxeBuilder({ page }).analyze();
9+
const accessibilityScanResults = await new AxeBuilder({ page })
10+
.exclude('[role="combobox"][aria-placeholder]') // aria-placeholder issue in supersearch is a false alarm (see https://github.com/w3c/aria/issues/2689)
11+
.analyze();
1112
await expect.soft(accessibilityScanResults.violations).toEqual([]);
1213
});
13-
*/
1414

1515
test('qualifier keys can be added from filter list', async ({ page }) => {
1616
await page.getByRole('main').getByRole('button').getByText('Ingår i bibliografi').click();
17+
await page.waitForResponse(
18+
(res) => res.url().includes('/supersearch?_q=') && res.status() === 200
19+
);
1720
await expect(page.getByRole('combobox').first()).toContainText('Ingår i bibliografi');
1821
await expect(page.getByRole('combobox').last()).toContainText('Ingår i bibliografi');
1922
await page.keyboard.press('Escape');
2023
await page.getByRole('main').getByRole('button').getByText('Bibliotek').first().click();
24+
await page.waitForResponse(
25+
(res) => res.url().includes('/supersearch?_q=') && res.status() === 200
26+
);
2127
await expect(page.getByRole('combobox').first()).toContainText('Bibliotek');
2228
});

‎packages/supersearch/src/lib/components/SuperSearch.svelte‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
DispatchChangeParams
3636
} from '$lib/types/superSearch.js';
3737
import { historyKeymap, standardKeymap } from '@codemirror/commands';
38+
import { draw, theme } from '$lib/extensions/theme';
3839
3940
export type ExpandedContentParams = {
4041
search: ReturnType<typeof useSearchRequest>;
@@ -224,6 +225,8 @@
224225
preventNewLine({ replaceWithSpace: true }),
225226
...(language ? [language] : []),
226227
placeholderCompartment.of(placeholderExtension(placeholder)),
228+
draw,
229+
theme,
227230
...extensions
228231
]);
229232

‎packages/supersearch/src/lib/extensions/lxlQualifierPlugin/qualifierDecoration.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class QualifierWidget extends WidgetType {
2727
toDOM(view: EditorView): HTMLElement {
2828
const container = document.createElement('span');
2929
container.className = 'atomic';
30+
container.setAttribute('style', 'margin-inline: 2px');
3031

3132
container.ondblclick = () => {
3233
if (this.props.atomicFrom != null && this.props.atomicTo != null) {
@@ -78,7 +79,7 @@ export function addDecorations(view: EditorView) {
7879
if (!qualifier.valueLabel && valueNode) {
7980
decorations.push(
8081
Decoration.mark({
81-
class: 'lxl-qualifier-value',
82+
class: 'lxl-qualifier-value editable',
8283
inclusive: false
8384
}).range(valueNode.from, valueNode.node.to)
8485
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { EditorView } from '@codemirror/view';
2+
import { drawSelection } from '@codemirror/view';
3+
4+
export const draw = drawSelection();
5+
6+
export const theme = EditorView.theme({
7+
'&.cm-focused .cm-cursor': {
8+
borderLeft: '1.4px solid #000',
9+
marginLeft: '0px'
10+
},
11+
'&.cm-editor .cm-selectionLayer': {
12+
zIndex: '1!important',
13+
pointerEvents: 'none'
14+
},
15+
'&.cm-focused .cm-selectionBackground': {
16+
background: '#3b82f640!important'
17+
}
18+
});

0 commit comments

Comments
 (0)