Skip to content

Conversation

@IMinchev64
Copy link
Contributor

@IMinchev64 IMinchev64 commented Jan 26, 2026

Closes #16575

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue with focusout handling in the grid by improving how the active node is cleared when focus moves outside the grid. The fix ensures proper handling of focus transitions between parent and child grids in hierarchical scenarios, particularly for cell merging.

Changes:

  • Refactored focusout event handler to check if focus remains within the grid element before clearing the active node
  • Extracted common condition (allowClear) to avoid duplication
  • Added test coverage for hierarchical grid focus transitions with cell merging

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
projects/igniteui-angular/grids/grid/src/grid-base.directive.ts Improved focusout logic to check if focus moved outside grid before clearing active node and reduced code duplication
projects/igniteui-angular/grids/grid/src/cell-merge.spec.ts Added test case verifying cell remerging behavior when focus moves from child to parent grid

@IMinchev64 IMinchev64 added 🛠️ status: in-development Issues and PRs with active development on them and removed ❌ status: awaiting-test PRs awaiting manual verification labels Jan 27, 2026
@IMinchev64
Copy link
Contributor Author

The original focusout logic only cleared the active node when the event target was tbody/thead/tfoot, which missed valid focus‑leave cases (e.g., clicking a parent grid).
This resulted in stale active state in child grids and kept merged cells unmerged.

Using a document:focusin check lets us reliably detect when focus moves outside the grid, regardless of which internal section triggered the event, and clear the active node consistently. This seems simpler, would cover the missing scenario, and avoids relying on specific section elements while also keeping the behavior stable for in‑grid focus changes.

@IMinchev64 IMinchev64 added ❌ status: awaiting-test PRs awaiting manual verification and removed 🛠️ status: in-development Issues and PRs with active development on them labels Jan 27, 2026
@mddragnev mddragnev added 🛠️ status: in-development Issues and PRs with active development on them and removed ❌ status: awaiting-test PRs awaiting manual verification labels Jan 30, 2026
@dkamburov dkamburov requested a review from MayaKirova February 3, 2026 14:14

// In hierarchical grids, activation can be cleared by child highlight logic, leaving an empty object.
// If merging is enabled, clear cached active indexes to allow merge state to restore.
if (!Object.keys(activeNode).length && this.hasCellsToMerge) {
Copy link
Contributor

@MayaKirova MayaKirova Feb 3, 2026

Choose a reason for hiding this comment

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

@IMinchev64 I don't think this is the best place to clear _activeRowIndexes , especially since this is very specific to the hierarchical grid.

Maybe in the clearActivation method in the hgrid navigation service, since that seems to be the thing that clears the active node:

Image

Or alternatively maybe emit the activeNodeChange event, since there's already an handler that listens for that event and updates the collection.

@IMinchev64 IMinchev64 requested a review from MayaKirova February 4, 2026 12:32
@IMinchev64 IMinchev64 changed the title fix(grid): improve focusout handling to clear active node correctly - master fix(hgrid): remerge cells after activation clears - master Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unmerged cell in hierarchical grid is not cleared even after activation/selection is moved to another grid.

4 participants