Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blocks): inconsistent language list behavior on hover in Firefox #8944

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export class FilterableListComponent<Props = unknown> extends WithDisposable(
const isActiveA = this.options.active?.(a);
const isActiveB = this.options.active?.(b);

if (isActiveA && !isActiveB) return -Infinity;
if (!isActiveA && isActiveB) return Infinity;
if (isActiveA && !isActiveB) return -1;
if (!isActiveA && isActiveB) return 1;

return this.listFilter?.(a, b) ?? Infinity;
return this.listFilter?.(a, b) ?? 0;
});
}

Expand Down
35 changes: 35 additions & 0 deletions tests/code/crud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,41 @@ test('language selection list should not close when hovering out of code block',
await expect(langLocator).toBeVisible();
});

test('language selection list should not change when hovering over its elements', async ({
page,
}) => {
await enterPlaygroundRoom(page);
await initEmptyCodeBlockState(page);

const codeBlockController = getCodeBlock(page);
await codeBlockController.codeBlock.hover();
await codeBlockController.clickLanguageButton();
await waitNextFrame(page, 100);

const langListLocator = codeBlockController.langList;
const langItemsLocator = langListLocator.locator('icon-button');

// checking first 4 language list items
for (let i = 0; i < 3; i++) {
const item = langItemsLocator.nth(i); // current item in language list
const nextItem = langItemsLocator.nth(i + 1); // next item in language list

await item.hover();

const initialItemText = await item.textContent();
const initialNextItemText = await nextItem.textContent();

await nextItem.hover();

const currentItemText = await item.textContent();
const currentNextItemText = await nextItem.textContent();

// text content should remain unchanged after next item receives focus
expect(initialItemText).toBe(currentItemText);
expect(initialNextItemText).toBe(currentNextItemText);
}
});

test('format text in code block', async ({ page }, testInfo) => {
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
Expand Down
Loading