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

Update preventScroll option in focus and focusElement #3177

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

nakjun12
Copy link

Enact-DCO-1.0-Signed-off-by: Nakjun Hwang wns450@gmail.com

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • At least one test case is included for this feature or bug fix
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

  • Improved scrolling behavior by adding a preventScroll parameter to the focusElement and extending focus in spotlight/Spotlight to include containerOption with preventScroll.

Resolution

  • The code works as intended, enabling more precise control over the scrolling behavior when focusing elements. This change was implemented to enhance the user navigation experience.
  • The preventScroll parameter was introduced because, when using spotlight.focus, the forced scrolling behavior caused discomfort in the user experience. Consequently, this change was implemented to improve the user experience by granting greater control over preventScroll in enact.

Additional Considerations

Separate PRs for focusElement and spotlight.focus
Considering splitting this PR into two: one for focusElement and another for spotlight.focus. This would allow for more focused review and testing of each feature.

Links

Focus with and without scrolling

Comments

To avoid affecting existing code:

A 4th argument was introduced in focusElement specifically for the preventScroll parameter.
For spotlight.focus, preventScroll was added to the existing containerOption.

Extensibility
The preventScroll parameter is designed for integration into other methods using focusElement.

Enact-DCO-1.0-Signed-off-by: Nakjun Hwang <wns450@gmail.com>
@codecov
Copy link

codecov bot commented Sep 17, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (b285309) 82.21% compared to head (716220c) 82.21%.

❗ Current head 716220c differs from pull request most recent head b17f48b. Consider uploading reports for the commit b17f48b to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3177   +/-   ##
========================================
  Coverage    82.21%   82.21%           
========================================
  Files          155      155           
  Lines         7141     7142    +1     
  Branches      1885     1887    +2     
========================================
+ Hits          5871     5872    +1     
  Misses         997      997           
  Partials       273      273           
Files Changed Coverage Δ
packages/spotlight/src/spotlight.js 43.73% <100.00%> (+0.17%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seunghoh
Copy link
Member

@nakjun12 Thanks for the PR. Do you have any user scenarios you mentioned about "the forced scrolling behavior caused discomfort in the user experience"? It would be appreciated if you also explain the scenario how we can use this preventScroll with Spotlight focus?

@nakjun12
Copy link
Author

nakjun12 commented Sep 20, 2023

@seunghoh Thank you for your review.

I encountered the issue while implementing an app with a user interface similar to Netflix.

During development, I noticed that scroll events for navigating up and down were conflicting with the automatic scrolling triggered by focus events. This conflict led to behaviors that diverged from the intended user experience.

To address this, I introduced the preventScroll option to give developers more control over the focus-scrolling behavior. This would allow developers to decide whether they want to handle scrolling through custom scroll events or allow the automatic focus-based scrolling.

If you have any more questions or need further clarification, feel free to ask. Thank you for considering my PR.

@0x64
Copy link
Member

0x64 commented Sep 25, 2023

I noticed that scroll events for navigating up and down were conflicting with the automatic scrolling triggered by focus events.

@nakjun12
Thank you for PR!

Could you please let us know what is the detail background scenario? We're working with a lot of media app developers and normally the issue is not a scrolling itself but scrolling distance so devs (at least we know) resolve their issue with Spotlight container. I'm not sure that your issue is the same as those, so it would be very helpful to understand what is your app's situation if you let us know.

We may accept your idea if the scenario is general and the issue is inevitable, and we're asking you about scenario to determine whether the new API would mislead app developers to write a kind of undesired pattern. I believe that you understand framework maintainers take care of app patterns seriously.

@nakjun12
Copy link
Author

nakjun12 commented Sep 28, 2023

@0x64 Thank you for reading my comments, and I understand that you're managing Spotlight carefully.

While developing an app with a UI similar to Netflix, I discovered conflicts between scrollIntoView and spotlight.focus. Specifically, I encountered issues when using spotlight.focus to navigate to areas outside of the currently visible screen area. The movement was unnatural, and I also had issue where animations that were supposed to occur during the transition would complete prematurely.

I addressed these issues with the preventScroll option, but this resulted in a more complex codebase as I had to control focus directly without spotlight.focus.

I aim to allow for more precise control over focus and scrolling behavior, even directly within spotlight.focus.

One concern I have is that my PR addresses both spotlight.focus and focusElement. If during the review process it's determined that addressing both in a single PR complicates the review, I'm open to considering splitting it into separate PRs.

Thank you once again for considering my PR. If you have any further questions or need clarification, please don't hesitate to ask.

@0x64
Copy link
Member

0x64 commented Oct 4, 2023

@nakjun12 Sorry for late response. What is scroll.interview, by the way? (It looks a typo of scrollIntoView by auto-completion or something.)

@seunghoh
Copy link
Member

seunghoh commented Oct 4, 2023

@nakjun12 Thanks for your detailed explanation. It sounds makes sense. I can't tell your PR will be merged immediately due to our version maintenance schedule, but we will definitely merge your PR when we start the next version(It contains new APIs, refactoring, API changes etc.)

@nakjun12
Copy link
Author

nakjun12 commented Oct 5, 2023

@0x64 @seunghoh
I've corrected the typo. Thank you for bringing it to my attention.
I appreciate both of you. Have a great day! 😄

@0x64
Copy link
Member

0x64 commented Oct 5, 2023

@nakjun12 If you don't mind, could we update your branch when we start the next version? We just reviewed briefly, and we may need to change API after in-depth review regarding API consistency. We don't want to make another branch for your suggestion, so we will update your branch directly in this pull request if you agree.

@nakjun12
Copy link
Author

@0x64 Of course, feel free to update my branch.

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.

None yet

3 participants