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

Add granular event hooks (for use in closing Dialogs) #911

Merged
merged 4 commits into from
Mar 10, 2023

Conversation

lyzadanger
Copy link
Contributor

Depends on #910
Fixes #900
Part of #77

This PR decomposes the functionality of useElementShouldClose into three separate, more-generic hooks, and aligns with useArrowKeyNavigation in the use of ListenerCollection for managing event listeners. This will allow more nuanced control for Dialogs.

There's some opportunity to DRY this out some in the future (especially in tests), but I started with the simplest approach possible here.

Just like with Dialog, I imagine we might make these hooks part of the package's public API (and deprecate useElementShouldClose). But let's do that later and separately.

@lyzadanger
Copy link
Contributor Author

lyzadanger commented Mar 9, 2023

I see the test misses. I'll address shortly. (sorted)

@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Merging #911 (d825f62) into main (3ab3010) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #911   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           60        63    +3     
  Lines          747       790   +43     
  Branches       271       284   +13     
=========================================
+ Hits           747       790   +43     
Impacted Files Coverage Δ
src/hooks/use-click-away.ts 100.00% <100.00%> (ø)
src/hooks/use-focus-away.ts 100.00% <100.00%> (ø)
src/hooks/use-key-press.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lyzadanger lyzadanger requested a review from acelaya March 9, 2023 21:37
@lyzadanger
Copy link
Contributor Author

I thought test coverage was happy but now it's not again. I'll deal with it later; it's trivial.

Copy link
Contributor

@acelaya acelaya left a comment

Choose a reason for hiding this comment

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

Looks good

Base automatically changed from update-listener-collection to main March 10, 2023 13:55
@lyzadanger lyzadanger merged commit db2a927 into main Mar 10, 2023
@lyzadanger lyzadanger deleted the add-event-hooks branch March 10, 2023 14:04
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.

Decompose useElementShouldClose into more targeted hooks
2 participants