Repository navigation
Conversation
When multiple nodes at the end of the tree were selected and deleted via Backspace, the focus fallback logic checked tree.lastNode without verifying whether it was also part of the selection. This caused focus to land on a node that was immediately deleted. When later siblings are unavailable or selected, findUnselectedFallback now finds the nearest unselected node preceding or following the selection. Also prevents single-node deletion from focusing the invisible root node when deleting the last root-level node.
✅ Deploy Preview for react-arborist ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This was referenced Nov 2, 2026
ccombe
added a commit
to ccombe/react-arborist
that referenced
this pull request
Nov 7, 2026
…election deletion When multiple nodes at the end of the tree are selected and deleted via Backspace, the focus fallback logic checked tree.lastNode without verifying whether it was also part of the selection. This caused focus to land on a node that was immediately deleted. When later siblings are unavailable or selected, findUnselectedFallback now finds the nearest unselected node preceding or following the selection. Also prevents single-node deletion from focusing the invisible root node when deleting the last root-level node. This folds jameskerr#402 into jameskerr#399.
Contributor
Author
|
Folded into #399 to reduce the number of open PRs under review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the focus fallback logic when deleting a multi-selection with Backspace, specifically when the selection extends to the end of the tree.
Follow-up to the review note on #399.
Problem
When multiple nodes were deleted using Backspace (
ids.length > 1),handleBackspacesearched for the next focus target among later siblings ofmostRecentNode:If the selection included the end of the tree (for example, selecting the last two nodes),
nextFocus.nextSiblingreached the end and evaluated tonull. The fallback then assignednextFocus = tree.lastNodewithout checking whetherlastNodewas also selected. As a result, focus was placed directly on a node that was immediately destroyed bytree.delete(ids).Similarly, in single-node deletion at the root level,
sib || parentfell back toroot(ROOT_ID), which is an internal virtual node not present invisibleNodes.Fix
nextSiblingyieldsnullor an already-selected node,findUnselectedFallbacksearchestree.visibleNodes:null(avoiding placing focus on deleted nodes).parent && !parent.isRootbefore falling back tonode.previf deleting the last root-level node.Testing