Skip to content

fix(ourlogs): stop drag-to-zoom writing multiple history entries - #119263

Merged
JoshuaKGoldberg merged 1 commit into
scttcper/chart-zoom-statefrom
joshgoldberg/logs-383-fix-drag-to-zoom-history
Jul 9, 2026
Merged

fix(ourlogs): stop drag-to-zoom writing multiple history entries#119263
JoshuaKGoldberg merged 1 commit into
scttcper/chart-zoom-statefrom
joshgoldberg/logs-383-fix-drag-to-zoom-history

Conversation

@JoshuaKGoldberg

@JoshuaKGoldberg JoshuaKGoldberg commented Jul 8, 2026

Copy link
Copy Markdown
Member

LogsAutoRefreshContext was missing the "only navigate() if the query changed" logic from other places like chartZoom. I added it there, then added a shared navigateIfQueryChanged helper to deduplicate the half-dozen places it was used.

Closes LOGS-383.

@linear-code

linear-code Bot commented Jul 8, 2026

Copy link
Copy Markdown

LOGS-383

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 8, 2026
Comment on lines -16 to -18
if (a.pathname !== b.pathname) {
return false;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Explanation] I don't think this is actually hittable still, so I didn't preserve it in navigateIfQueryChanged. Someone please let me know if I'm wrong!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this may have just been an early cheap check rather than the more expensive json stringify'ing one 🤔

@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 989368d. Configure here.

@JoshuaKGoldberg
JoshuaKGoldberg marked this pull request as ready for review July 8, 2026 21:32
@JoshuaKGoldberg
JoshuaKGoldberg requested review from a team as code owners July 8, 2026 21:32
Dragging to zoom on the logs chart pushed several browser-history entries per
drag, so hitting back once did not return to the previous query.

A datetime selection change trips the auto-refresh toggle's "disable on selection
change" effect, which calls setAutorefresh. That callback navigated
unconditionally and is recreated on every location change, so it re-fired in a
loop, each pass pushing a redundant same-URL entry. Only navigate when the query
actually changes.

Extract that guard into a shared navigateIfQueryChanged util and route the other
existing copies (chart zoom, page filters, spans query params) through it too.

Fixes LOGS-383
Co-Authored-By: Claude <noreply@anthropic.com>
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(logs): Stop drag-to-zoom writing multiple history entries fix(ourlogs): stop drag-to-zoom writing multiple history entries Jul 8, 2026
@JoshuaKGoldberg
JoshuaKGoldberg force-pushed the joshgoldberg/logs-383-fix-drag-to-zoom-history branch from 989368d to 1c92e0e Compare July 8, 2026 21:33
@JoshuaKGoldberg
JoshuaKGoldberg requested a review from gggritso July 9, 2026 12:36
Comment on lines -16 to -18
if (a.pathname !== b.pathname) {
return false;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this may have just been an early cheap check rather than the more expensive json stringify'ing one 🤔

@gggritso gggritso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍🏻 makes sense, thanks!

It's interesting, I feel like there are very few times we actually want a navigation to the same URL to re-render the page, I'm wondering if we should set that as the default at the useNavigate level? Just food for thoughts, maybe people in the FE channel will have opinions!

@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

I like that! Posted on Slack: https://sentry.slack.com/archives/C8V02RHC7/p1783611498666769

@JoshuaKGoldberg
JoshuaKGoldberg merged commit d6544d7 into scttcper/chart-zoom-state Jul 9, 2026
64 checks passed
@JoshuaKGoldberg
JoshuaKGoldberg deleted the joshgoldberg/logs-383-fix-drag-to-zoom-history branch July 9, 2026 15:38
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