-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Focus first element in scope if nodeToRestore does not exist #3385
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
ee606b6
FocusScope tree
snowystinger e73e012
simplify logic
snowystinger 5619398
Add test and handle cleanup and restoring
snowystinger 5d00fd7
add some comments
snowystinger b09322a
reorder for more readability
snowystinger 1d46fd3
Merge branch 'main' into focusscope-tree
snowystinger 579882f
fix types
snowystinger 7c672dc
Fix menu opens dialog
snowystinger df4b2ed
Rename variable so it's easier to read
snowystinger 2766d07
fix lint
snowystinger 33c79ad
Merge branch 'main' into focusscope-tree
3169008
human linting
snowystinger 10f8dda
fix restore but not contain
snowystinger 93699f9
fix lint
snowystinger 7abd547
fix 17 tests
snowystinger 215c8af
Merge branch 'main' into focusscope-tree
snowystinger b64696a
Review updates
snowystinger d539c1d
Merge branch 'main' into focusscope-tree
snowystinger ea8b0fd
Merge branch 'main' into focusscope-tree
snowystinger c816870
fix logic for nodeToRestore
snowystinger cc4c47a
fix test and lint
snowystinger 6f8f700
Merge branch 'main' into focusscope-tree
snowystinger d1004e6
Focus first element in scope if nodeToRestore does not exist
devongovett 7bc1c1d
Focus first item in collection when focused item is removed
devongovett 8328f20
Contain focus when a nested scope is active
devongovett e0f2c35
Merge branch 'focusscope-tree' into focusscope2
devongovett bb7aa46
Revert focusing the first item for now
devongovett 4c37cf6
Add focus scopes around some collection components
devongovett d454694
Ensure activeScope is in the tree
devongovett b41fe1f
Track active scope even when contain and restoreFocus are false
devongovett daceb1a
Merge branch 'main' of github.com:adobe/react-spectrum into focusscop…
devongovett e9e2d24
Merge branch 'main' into focusscope-restore
dd6ee09
Merge branch 'main' into focusscope-restore
snowystinger 53455a6
Add test for deleting active row
snowystinger c2621be
add more tests
snowystinger 224b48f
Merge branch 'main' into focusscope-restore
snowystinger 9240835
fix 17 tests
snowystinger e46122a
Add focus scopes around collection type components
snowystinger 14e1501
use a less fragile test
snowystinger 7d02ff4
Merge branch 'main' into focusscope-restore
aec583d
revert useSelectableCollection changes
devongovett fdb9acf
Merge branch 'main' of github.com:adobe/react-spectrum into focusscop…
LFDanLu 54831be
removing extraneous FocusScopes
LFDanLu e299e10
Merge branch 'main' into focusscope-restore
LFDanLu 504b933
Merge branch 'main' into focusscope-restore
devongovett a25fe6e
fix merge
devongovett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ let defaultItems = [ | |
| export function Example(props: any = {}) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| const [selectedKeys, setSelectedKeys] = useState<Selection>(props.defaultSelectedKeys || new Set()); | ||
| let [items, setItems] = useState(defaultItems); | ||
|
|
||
| let ref = useRef(null); | ||
| return ( | ||
| <ActionBarContainer height={props.containerHeight || 300}> | ||
|
|
@@ -88,28 +89,26 @@ export function Example(props: any = {}) { | |
| } | ||
| setItems(newItems); | ||
| setSelectedKeys(new Set()); | ||
| // TODO need to solve restore focus when the row we arrived from is deleted, tableview ref is not focusable | ||
| // ref.current.focus(); | ||
| } | ||
| } | ||
| })}> | ||
| <Item key="edit"> | ||
| <Item key="edit" textValue="Edit"> | ||
| <Edit /> | ||
| <Text>Edit</Text> | ||
| </Item> | ||
| <Item key="copy"> | ||
| <Item key="copy" textValue="Copy"> | ||
| <Copy /> | ||
| <Text>Copy</Text> | ||
| </Item> | ||
| <Item key="delete"> | ||
| <Item key="delete" textValue="Delete"> | ||
| <Delete /> | ||
| <Text>Delete</Text> | ||
| </Item> | ||
| <Item key="move"> | ||
| <Item key="move" textValue="Move"> | ||
| <Move /> | ||
| <Text>Move</Text> | ||
| </Item> | ||
| <Item key="duplicate"> | ||
| <Item key="duplicate" textValue="Duplicate"> | ||
| <Duplicate /> | ||
| <Text>Duplicate</Text> | ||
| </Item> | ||
|
|
||
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
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
Oops, something went wrong.
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.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand the logic here:
What about when a sibling focus scope mounts when the first sibling scope is active? Wouldn't this evaluate in such a way that parentScope of the second sibling is set to the first sibling scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would, yes. This is essentially the DialogContainer + Menu case. For our purposes, I think this is ok. The user would expect focus to return to the previously active scope when the new one unmounts.
Actually, in most cases, the parent should really be the active scope at the time the new scope mounts. The case where this is not true is if multiple nested scopes mount at the same time.