SceneTimeRange: Preserve explicit timezone values in URL state #1279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Dashboard links with "Include current time range" are not preserving timezone settings when navigating between dashboards. This affects users who set their dashboards to use "browser" timezone or other explicit timezone values.
When a dashboard has timezone set to "browser" and a user clicks a dashboard link:
timezone=browser
timezone=Europe%2FMadrid
(or user's local timezone)Root cause:
The
SceneTimeRange.getUrlState()
method was callingthis.getTimeZone()
which resolves timezone values for calculations. This method:state.timeZone
value if setgetTimeZone()
from @grafana/dataThe problem is that
getTimeZone()
resolves "browser" to the actual browser timezone (e.g., "Europe/Madrid"). When this resolved value is used in URL state, it becomes permanent in the URL, losing the user's preference for "browser" timezone.Why this matters:
Related:
Solution
Modified
SceneTimeRange.getUrlState()
to preserve explicit timezone values:How this works:
state.timeZone
is explicitly set (e.g., "browser", "UTC", "America/New_York"), preserve it in the URLstate.timeZone
is undefined (not set), fall back togetTimeZone()
to resolve from parent or defaultWhat doesn't change:
getTimeZone()
(unchanged)How to test
timezone=browser
(not resolved)timezone=UTC
timezone=America%2FNew_York
)yarn test SceneTimeRange.test --no-watch
Edge cases to verify:
timezone=browser
→ Link URL hastimezone=browser
timezone=UTC
→ Link URL hastimezone=UTC
📦 Published PR as canary version:
6.39.9--canary.1279.18576011857.1
✨ Test out this PR locally via: