Skip to content

fix(explore): drop inherit/custom time shifts when switching to a viz that can't honor them#40865

Open
jesperct wants to merge 1 commit into
apache:masterfrom
jesperct:fix/time-shift-inherit-persists-on-viz-type-change
Open

fix(explore): drop inherit/custom time shifts when switching to a viz that can't honor them#40865
jesperct wants to merge 1 commit into
apache:masterfrom
jesperct:fix/time-shift-inherit-persists-on-viz-type-change

Conversation

@jesperct

@jesperct jesperct commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

When you convert a chart from Big Number with Time Comparison or Table (both offer the "Inherit range from time filter" and "Custom" time shifts) into a timeseries chart such as Line or Bar, the inherit/custom value was carried over into the new chart's Time shift control. The timeseries Advanced Analytics "Time shift" reuses the same time_compare form-data key but does not offer those options, and because the control is free-form the value was accepted and left as a stray tag the user had to delete by hand on every edit.

StandardizedFormData.transform preserves shared controls across viz-type switches. It now drops inherit/custom from time_compare when the target viz type's Time shift control does not list them as choices. Portable relative shifts (e.g. "1 year ago") are still carried over, and inherit/custom are preserved when switching between viz types that both support them (e.g. Table to Big Number).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After converting a Big Number (Time Comparison) chart with Time shift = "Inherit" into a Line chart:

Before After
before after

TESTING INSTRUCTIONS

  1. Create a Big Number with Time Comparison (or Table) chart.
  2. In Time Comparison, set Time shift to Inherit range from time filter.
  3. Switch the visualization type to Line Chart (or Bar).
  4. Open Advanced Analytics → Time Comparison.
  5. The Time shift field is empty; previously it showed a lingering inherit tag.

Unit tests in standardizedFormData.test.ts cover both stripping (target viz without inherit/custom) and preservation (target viz that supports them).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

…onor them

Converting a chart from Big Number / Table period-over-period (which offer
"inherit" and "custom" time shifts) to a timeseries chart carried the
inherit/custom value into the new chart's Time shift control, where it
lingered as a tag the user had to remove manually. The timeseries
advanced-analytics Time shift reuses the same `time_compare` key but does
not offer those choices, and since the control is free-form it accepted them.

standardizedFormData.transform now strips inherit/custom from `time_compare`
when the target viz type's control does not list them as choices, and keeps
them when it does (e.g. Table to Big Number).
@bito-code-review

bito-code-review Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1e951e

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/explore/controlUtils/standardizedFormData.test.ts - 1
    • Inconsistent test setup pattern · Line 364-386
      The new test registers `target_viz_inherit` inside the test body, while existing tests register their mock viz types in `beforeAll`. This creates an inconsistent setup pattern within the same describe block.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/src/explore/controlUtils/standardizedFormData.test.ts - 1
Review Details
  • Files reviewed - 2 · Commit Range: ceb4018..ceb4018
    • superset-frontend/src/explore/controlUtils/standardizedFormData.test.ts
    • superset-frontend/src/explore/controlUtils/standardizedFormData.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit ceb4018
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a27034a26e9a20008ad9a48
😎 Deploy Preview https://deploy-preview-40865--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.14%. Comparing base (7c7ab88) to head (ceb4018).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #40865   +/-   ##
=======================================
  Coverage   64.14%   64.14%           
=======================================
  Files        2652     2652           
  Lines      143488   143501   +13     
  Branches    33110    33115    +5     
=======================================
+ Hits        92042    92052   +10     
- Misses      49837    49840    +3     
  Partials     1609     1609           
Flag Coverage Δ
javascript 67.87% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

Pull request overview

This PR fixes an Explore UX issue where inherit/custom time-shift markers (stored under the shared time_compare form-data key) could “stick” when switching from viz types that support them (e.g. Table / Big Number period-over-period) to viz types whose Time shift control does not offer those options (e.g. timeseries charts).

Changes:

  • Add a StandardizedFormData.dropUnsupportedTimeShifts() step during viz-type transform to remove inherit/custom from controlsState.time_compare.value when the target viz’s time_compare control choices don’t include them.
  • Preserve portable relative offsets (e.g. 1 year ago) and preserve inherit/custom when the target viz does support them (via its control choices).
  • Add unit tests covering both stripping and preservation behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
superset-frontend/src/explore/controlUtils/standardizedFormData.ts Filters time_compare during viz-type switching based on the target control’s supported choices.
superset-frontend/src/explore/controlUtils/standardizedFormData.test.ts Adds unit coverage for dropping vs preserving inherit/custom during transforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants