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

feat: Support for Multiple Refs in useClickAway #2593

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

philipprus
Copy link

Description

  1. Updated useClickAway Hook:
    • The useClickAway hook was enhanced to accept either a single RefObject<HTMLElement | null> or an array of RefObject<HTMLElement | null>[].
    • The hook now checks if the clicked element is outside of all the provided refs before triggering the onClickAway callback. This makes the hook more flexible and capable of handling multiple elements.
  2. Consolidated Storybook Example:
    • The Storybook demo was updated to demonstrate both the single ref and multiple refs usage within the same example.
    • The example includes:
    • A red box with a single ref that triggers the onClickAway callback when a click is detected outside of it.
    • A green and a blue box, each with its own ref, that together trigger a different onClickAway callback when a click is detected outside of either box.
    • This setup effectively showcases the new functionality of the useClickAway hook in a single, concise demonstration.

Example in SandBox

Go to sandbox

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • Read the Contributing Guide
  • Perform a code self-review
  • Comment the code, particularly in hard-to-understand areas
  • Add documentation
  • Add hook's story at Storybook
  • Cover changes with tests
  • Ensure the test suite passes (yarn test)
  • Provide 100% tests coverage
  • Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • Make sure types are fine (yarn lint:types).

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.

1 participant