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

fix(explore): Update search bar query on filter change #88473

Merged
merged 4 commits into from
Apr 2, 2025

Conversation

nikkikapadia
Copy link
Member

The search bar was not updating automatically when a query was changed causing schema hints to be added on top of the previously saved query (which may not be what the user has currently in their search bar). I've provided and option to turn this on and only for filter actions.

Addresses this bug and this bug

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 1, 2025
@@ -43,6 +43,7 @@ type ResetFocusOverrideAction = {type: 'RESET_FOCUS_OVERRIDE'};
type DeleteTokenAction = {
token: ParseResultToken;
type: 'DELETE_TOKEN';
handleSearch?: (query: string) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to initialize useQueryBuilderState and pass along handleSearch as a prop? Defining it on each dispatch is like saying it could possibly change at each call. I think if we can initialize the hook with it, then passing it down and using it might be easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

problem is handleSearch needs the state from useQueryBuilderState to initialize the function. I agree it's kind of janky, wonder if there's a better workaround

Copy link
Member

Choose a reason for hiding this comment

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

@nikkikapadia React assumes that reducers are pure and have no side effects (see docs for useReducer). Adding side effects can lead to some very hard to track down bugs, so we will need to find a different solution.

I'll take some time to look over the issue and see if I can recommend a different path

Copy link
Member Author

Choose a reason for hiding this comment

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

I know that there were supposed to be improvements made to the search bar; if this feature is coming soon i don't mind deprioritizing this PR

@nikkikapadia nikkikapadia marked this pull request as ready for review April 1, 2025 20:07
@nikkikapadia nikkikapadia requested review from a team as code owners April 1, 2025 20:07
@nikkikapadia nikkikapadia requested a review from malwilley April 1, 2025 20:07
@malwilley
Copy link
Member

@nikkikapadia can you just use the onChange handler instead of onSearch? That should fire every time the search query changes rather than on enter.

@nikkikapadia
Copy link
Member Author

@nikkikapadia can you just use the onChange handler instead of onSearch? That should fire every time the search query changes rather than on enter.

works great, thanks for the help! 😌

@nikkikapadia nikkikapadia merged commit ed4dd08 into master Apr 2, 2025
41 checks passed
@nikkikapadia nikkikapadia deleted the nikki/fix/search-bar-not-updating branch April 2, 2025 15:46
jan-auer added a commit that referenced this pull request Apr 2, 2025
* master: (96 commits)
  fix(autofix): fix highlight popup behavior (#88552)
  🔧 chore: introduce workflow engine ui links ff (#88569)
  feat(pipeline): Add CoveragePageWrapper component and tests for it (#88519)
  feat(taskworker):Make sdk tasks taskworker compatible (#88488)
  chore(flamegraph): Updating wording to trace (#88516)
  feat(shared-views): Create `GET` `group-search-view/starred` endpoint (#88398)
  DI-612: print flaky pytest errors to log (v2) (#88512)
  chore(nav): Update banner copy (#88566)
  feat(sentryapps): add RPC method to get all installation component contents (#88179)
  chore(issue summary): Add limit to query (#88563)
  fix(dashboards): Add limit suggestion to validation (#88436)
  feat(checkout): show starting PAYG prices (#88510)
  ✨ feat(aci): add workflow_id when creating an ephemeral rule in noa (#88520)
  fix(billing): hide pay now button for self serve partners (#88504)
  chore(HC): Re-adds logging with a low sample rate for cache hits/misses on options (#88464)
  fix(logs): Upgrade sentry log integration to fix dogfooding issues (#88561)
  chore(issue summary): Remove dividers from AI summary alert (#88554)
  feat(insights): Enable bubbles in full-screen mode (#88445)
  fix(explore): Update search bar query on filter change (#88473)
  chore(dependencies): Upgrade drf-spectacular (#88459)
  ...
andrewshie-sentry pushed a commit that referenced this pull request Apr 8, 2025
The search bar was not updating automatically when a query was changed
causing schema hints to be added on top of the previously saved query
(which may not be what the user has currently in their search bar). I've
provided and option to turn this on and only for filter actions.

Addresses [this
bug](https://www.notion.so/sentry/Getting-rid-of-fields-from-the-search-bar-doesn-t-update-url-1c08b10e4b5d8058b1afc7d83f532be7?pvs=4)
and [this
bug](https://www.notion.so/sentry/Unsubmitted-changes-get-reset-and-cleared-on-updates-1c08b10e4b5d80e294fde2af6e850e40?pvs=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants