Skip to content

Conversation

@spliffone
Copy link
Member

See #1345

Describe in detail what your merge request does and why. Add relevant
screenshots and reference related issues via Closes #XY or Related to #XY.


@spliffone spliffone requested a review from a team as a code owner January 30, 2026 06:37
@spliffone spliffone marked this pull request as draft January 30, 2026 06:37
@gemini-code-assist
Copy link

Summary of Changes

Hello @spliffone, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust and flexible solution for keyboard navigation within grid-like structures in Angular applications. By leveraging a rectangle-based navigation service, it enables seamless keyboard interaction across diverse CSS layouts, including CSS Grid and Flexbox. The new directives provide comprehensive ARIA support and implement a roving tabindex pattern, significantly enhancing the accessibility of grid components.

Highlights

  • Grid Keyboard Navigation: Introduces SiGridDirective and SiGridCellDirective to enable comprehensive keyboard navigation within grid layouts, adhering to WAI-ARIA grid patterns.
  • Rectangle-Based Navigation Logic: Implements SiGridNavigationService which uses element bounding rectangles to determine cell relationships and navigate, making it compatible with any CSS layout (Grid, Flexbox, tables).
  • Advanced Navigation Features: Supports arrow key navigation, Home/End for row/grid boundaries, and Page Up/Down for vertical jumps, with configurable wrapping modes ('nowrap', 'continuous', 'loop') and RTL support.
  • Accessibility and Dynamic ARIA: Automatically manages ARIA attributes like role, tabindex, aria-disabled, aria-rowcount, aria-colcount, and dynamically derives row/column indices for cells in flat layouts.
  • Roving Tabindex: Implements the roving tabindex pattern, ensuring only one navigable cell is in the tab sequence at a time for improved accessibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new set of directives for creating accessible grids with keyboard navigation. The implementation is robust, leveraging rectangle-based positioning for layout independence, which is a great approach. The code is well-structured and uses modern Angular signals effectively. I've left a few comments with suggestions for minor improvements, mainly around code duplication, documentation accuracy, and improving maintainability by removing magic numbers. Overall, this is a solid contribution.

Comment on lines +158 to +196
private calculateDistance(from: DOMRect, to: DOMRect, direction: Direction): number {
if (direction === 'right' || direction === 'left') {
// Horizontal movement: prioritize vertical alignment
const verticalOverlap = this.calculateOverlap(from.top, from.bottom, to.top, to.bottom);
const horizontalDist = Math.abs(
direction === 'right' ? to.left - from.right : from.left - to.right
);

// If well-aligned (>50% overlap), use horizontal distance
// Otherwise, heavily penalize misalignment
if (verticalOverlap > 0.5) {
return horizontalDist;
} else {
// Add penalty based on vertical misalignment
const verticalMisalignment = Math.abs(
(from.top + from.bottom) / 2 - (to.top + to.bottom) / 2
);
return horizontalDist * 2 + verticalMisalignment * 10;
}
} else {
// Vertical movement: prioritize horizontal alignment
const horizontalOverlap = this.calculateOverlap(from.left, from.right, to.left, to.right);
const verticalDist = Math.abs(
direction === 'down' ? to.top - from.bottom : from.top - to.bottom
);

// If well-aligned (>50% overlap), use vertical distance
// Otherwise, heavily penalize misalignment
if (horizontalOverlap > 0.5) {
return verticalDist;
} else {
// Add penalty based on horizontal misalignment
const horizontalMisalignment = Math.abs(
(from.left + from.right) / 2 - (to.left + to.right) / 2
);
return verticalDist * 2 + horizontalMisalignment * 10;
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The calculateDistance method uses several magic numbers (0.5, 2, 10) for its heuristics. To improve readability and maintainability, consider extracting these values into named constants at the class level, for example ALIGNMENT_THRESHOLD, DISTANCE_FACTOR, and MISALIGNMENT_PENALTY.

Comment on lines +85 to +87
* Get all cells regardless of mode (explicit rows or flat).
* @internal
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment here is a bit misleading. It states that it gets cells 'regardless of mode (explicit rows or flat)', but the current implementation only supports the flat mode by using directCells. It would be clearer to update the comment to reflect the current implementation, for example: 'Get all cells for a flat grid layout.'

Comment on lines +97 to +120
readonly derivedRows = computed<DerivedRow<SiGridCellDirective>[]>(() => {
// Derive rows from cell positions
const cells = this.directCells();
const rowMap = new Map<number, SiGridCellDirective[]>();

cells.forEach(cell => {
const rect = cell.getBoundingRect();
const rowKey = Math.round(rect.top);

if (!rowMap.has(rowKey)) {
rowMap.set(rowKey, []);
}
rowMap.get(rowKey)!.push(cell);
});

// Sort rows by Y, cells within rows by X
return Array.from(rowMap.entries())
.sort(([y1], [y2]) => y1 - y2)
.map(([yPosition, rowCells], index) => ({
cells: rowCells.sort((a, b) => a.getBoundingRect().left - b.getBoundingRect().left),
yPosition,
rowIndex: index + 1
}));
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic to derive rows from cell positions is duplicated here and in the private groupCellsByRows method within SiGridNavigationService. To improve maintainability and centralize grid calculation logic, consider extracting this functionality into a public method in SiGridNavigationService. This new method could be used by both the directive and the service's internal methods.

@github-actions
Copy link

Code Coverage

@github-actions
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants