Skip to content

Refactor search context #384

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 3 commits into from
May 6, 2025
Merged

Refactor search context #384

merged 3 commits into from
May 6, 2025

Conversation

davidjgoss
Copy link
Contributor

@davidjgoss davidjgoss commented May 6, 2025

🤔 What's changed?

The functionality supporting search, having been gradually extended over time, was a bit confusing to work with for both consumers and maintainers. This rework aims to reduce the amount and complexity of code involved, and make it easier for consumers to add search to their app either out of the box or with custom handling.

Specifically:

  • Naming is clearer
  • Implementation details that should stay internal - like the React context - are not exported
  • <ControlledSearchProvider/> provides a low-level usage with value and onChange allowing you to manage the state yourself - this will be helpful for consumers integrating with framework-specific routers, or other kinds of state management
  • <InMemorySearchProvider/> is a thin useState wrapper around the former - fine for many use cases
  • <UrlSearchProvider/> also wraps the controlled one and syncs with query parameters on the URL
  • useSearch continues to be the way you consume/update the context, and this is dogfooded in our own components

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)
  • 💥 Breaking change (incompatible changes to the API)

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

Copy link

netlify bot commented May 6, 2025

Deploy Preview for cucumber-react-preview ready!

Name Link
🔨 Latest commit f8b9e0a
🔍 Latest deploy log https://app.netlify.com/sites/cucumber-react-preview/deploys/681a1aad18185c00070a259c
😎 Deploy Preview https://deploy-preview-384--cucumber-react-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@davidjgoss davidjgoss marked this pull request as ready for review May 6, 2025 16:18
@davidjgoss davidjgoss merged commit f6316c8 into main May 6, 2025
6 checks passed
@davidjgoss davidjgoss deleted the refactor-search-context branch May 6, 2025 16:18
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