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

STCOM-1372 Use mutationobserver for focus management in repeatable field #2376

Merged
merged 5 commits into from
Oct 28, 2024

Conversation

JohnC-80
Copy link
Contributor

@JohnC-80 JohnC-80 commented Oct 25, 2024

This is cited in a hanful of issues.... STCOM-1372 is the first. This solution uses a useEffect/MutationObserver combination for focus management in repeatable field.

Since state for RepeatableField is kept outside of the component, DOM state is the main way we have to control this behavior at the component level.

Pseudo-logic for this is as follows:
Manage focus only if the user has already interacted with the list (via onFocus handler)
When an item is added, move focus to the first focusable element within that item.
If items are removed from the list, focus the first focusable element within the item's previous sibling.

Copy link

github-actions bot commented Oct 25, 2024

Bigtest Unit Test Results

    1 files  ±0      1 suites  ±0   16s ⏱️ -1s
1 528 tests ±0  1 520 ✅ ±0  8 💤 ±0  0 ❌ ±0 
1 530 runs  ±0  1 522 ✅ ±0  8 💤 ±0  0 ❌ ±0 

Results for commit 537ef98. ± Comparison against base commit 4b06eed.

♻️ This comment has been updated with latest results.

@JohnC-80 JohnC-80 requested a review from vashjs October 28, 2024 15:48
@JohnC-80 JohnC-80 marked this pull request as ready for review October 28, 2024 15:48
Copy link
Contributor

@vashjs vashjs left a comment

Choose a reason for hiding this comment

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

@JohnC-80 thank you for solving this problem, looks good to me.

Copy link

@JohnC-80 JohnC-80 merged commit d7e23fb into master Oct 28, 2024
15 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 28, 2024
…eld (#2376)

* use mutationobserver for focusmanagement in repeatable field

* cleanup RFContent, mild refactor, check for RF-items addition, deletion, specifically.

* use state to check if the user has interacted with the repeatableField

* add comments for conditionals

* Update CHANGELOG.md
@zburke zburke deleted the STCOM-1372v2 branch October 31, 2024 12:03
zburke pushed a commit that referenced this pull request Oct 31, 2024
…eld (#2376)

* use mutationobserver for focusmanagement in repeatable field

* cleanup RFContent, mild refactor, check for RF-items addition, deletion, specifically.

* use state to check if the user has interacted with the repeatableField

* add comments for conditionals

* Update CHANGELOG.md

(cherry picked from commit d7e23fb)
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