Skip to content

Commit 6861750

Browse files
committed
fixup! ✨(frontend) improve NVDA navigation in DocShareModal
1 parent ea3605a commit 6861750

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,15 +763,34 @@ test.describe('Doc Editor', () => {
763763
await expect(searchContainer.getByText(docChild2)).toBeVisible();
764764
await expect(searchContainer.getByText(randomDoc)).toBeHidden();
765765

766-
// use keydown to select the second result
766+
// Try keyboard navigation first
767767
await page.keyboard.press('ArrowDown');
768-
await page.keyboard.press('Enter');
768+
769+
// Check what's selected after ArrowDown
770+
const activeAfterDown = searchContainer.locator(
771+
'.quick-search-item.selected, .quick-search-item:focus, [aria-selected="true"]',
772+
);
773+
const activeCountAfterDown = await activeAfterDown.count();
774+
775+
if (activeCountAfterDown > 0) {
776+
const activeTextAfterDown = await activeAfterDown.first().textContent();
777+
778+
// If the selected item is not the expected one, try direct click instead
779+
if (!activeTextAfterDown?.includes(docChild2)) {
780+
await searchContainer.getByText(docChild2).click();
781+
} else {
782+
await page.keyboard.press('Enter');
783+
}
784+
} else {
785+
await searchContainer.getByText(docChild2).click();
786+
}
769787

770788
// Wait for the search container to disappear, indicating selection was made
771789
await expect(searchContainer).toBeHidden();
772790

773791
// Wait for the interlink to be created and rendered
774792
const editor = page.locator('.ProseMirror.bn-editor');
793+
775794
const interlink = editor.getByRole('link', {
776795
name: docChild2,
777796
});

src/frontend/apps/e2e/__tests__/app-impress/doc-member-create.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ test.describe('Document create member', () => {
2626

2727
await page.getByRole('button', { name: 'Share' }).click();
2828

29-
const inputSearch = page.getByRole('combobox', {
30-
name: 'Quick search input',
31-
});
29+
const inputSearch = page.getByTestId('quick-search-input');
30+
3231
await expect(inputSearch).toBeVisible();
3332

3433
// Select user 1 and verify tag

src/frontend/apps/impress/src/components/quick-search/QuickSearch.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ export const QuickSearch = ({
4444
}: PropsWithChildren<QuickSearchProps>) => {
4545
const ref = useRef<HTMLDivElement | null>(null);
4646
const listId = useId();
47-
const hasResults = Boolean(children);
4847
const NO_SELECTION_VALUE = '__none__';
4948
const [userInteracted, setUserInteracted] = useState(false);
5049
const [selectedValue, setSelectedValue] = useState(NO_SELECTION_VALUE);
51-
const isExpanded = userInteracted && hasResults;
50+
const isExpanded = userInteracted;
5251

5352
const handleValueChange = (val: string) => {
5453
if (userInteracted) {
@@ -82,7 +81,6 @@ export const QuickSearch = ({
8281
onFilter={onFilter}
8382
placeholder={placeholder}
8483
listId={listId}
85-
hasResults={hasResults}
8684
isExpanded={isExpanded}
8785
onUserInteract={handleUserInteract}
8886
>

src/frontend/apps/impress/src/components/quick-search/QuickSearchInput.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Props = {
1717
children?: ReactNode;
1818
withSeparator?: boolean;
1919
listId?: string;
20-
hasResults?: boolean;
2120
onUserInteract?: () => void;
2221
isExpanded?: boolean;
2322
};
@@ -29,7 +28,6 @@ export const QuickSearchInput = ({
2928
children,
3029
withSeparator: separator = true,
3130
listId,
32-
hasResults,
3331
onUserInteract,
3432
isExpanded,
3533
}: Props) => {
@@ -65,7 +63,7 @@ export const QuickSearchInput = ({
6563
<Command.Input
6664
autoFocus={true}
6765
aria-label={t('Quick search input')}
68-
aria-expanded={isExpanded ?? hasResults}
66+
aria-expanded={isExpanded}
6967
aria-controls={listId}
7068
onClick={(e) => {
7169
e.stopPropagation();

0 commit comments

Comments
 (0)