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: ensure grid has tabbable elements after it becomes visible (#8102) (CP: 24.5) #8105

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions packages/grid/src/vaadin-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,9 @@ export const GridMixin = (superClass) =>
e.stopPropagation();
this.__tryToRecalculateColumnWidthsIfPending();

// Ensure header and footer have tabbable elements
this._resetKeyboardNavigation();

requestAnimationFrame(() => {
this.__scrollToPendingIndexes();
});
Expand Down
17 changes: 14 additions & 3 deletions packages/grid/test/hidden-grid.common.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync, nextFrame, oneEvent } from '@vaadin/testing-helpers';
import { fixtureSync, nextFrame, nextRender, oneEvent } from '@vaadin/testing-helpers';
import { sendKeys } from '@web/test-runner-commands';
import sinon from 'sinon';
import { fire, flushGrid, getBodyCellContent, infiniteDataProvider } from './helpers.js';
import { fire, flushGrid, getBodyCellContent, getHeaderCell, infiniteDataProvider } from './helpers.js';

describe('hidden grid', () => {
let grid;

describe('initially hidden', () => {
beforeEach(() => {
beforeEach(async () => {
grid = fixtureSync(`
<vaadin-grid style="height: 200px; width: 200px;" hidden size="1">
<vaadin-grid-column header="foo"></vaadin-grid-column>
</vaadin-grid>
`);
await nextRender();
grid.querySelector('vaadin-grid-column').renderer = (root, _, model) => {
root.textContent = model.index;
};
Expand All @@ -31,6 +33,15 @@ describe('hidden grid', () => {
await nextFrame();
expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('0');
});

it('should make it possible to Tab to header', async () => {
grid.removeAttribute('hidden');
await oneEvent(grid, 'animationend');
await nextFrame();

await sendKeys({ press: 'Tab' });
expect(grid.shadowRoot.activeElement).to.equal(getHeaderCell(grid, 0, 0));
});
});

describe('hiding the grid', () => {
Expand Down
Loading