Skip to content

feat(dashboard): implement boolean conditional formatting#36338

Merged
rusackas merged 11 commits into
apache:masterfrom
edison-lhk:feature/conditional-formatting-boolean-improvement
Dec 4, 2025
Merged

feat(dashboard): implement boolean conditional formatting#36338
rusackas merged 11 commits into
apache:masterfrom
edison-lhk:feature/conditional-formatting-boolean-improvement

Conversation

@edison-lhk
Copy link
Copy Markdown
Contributor

@edison-lhk edison-lhk commented Nov 30, 2025

User description

SUMMARY

This PR introduces boolean conditional formatting to the table chart’s conditional formatting configuration.

Until now, conditional formatting only worked for numeric and string columns. With this update, boolean columns are also supported through the following operators:

  1. isTrue: highlight cells with a value of true
  2. isFalse: highlight cell with a value of false
  3. isNull: highlight empty or null cells
  4. isNull: highlight non-empty cells

These enhancements would make conditional formatting more flexible and easier to use, especially for tables that include different data types.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screencast_from_2025-11-29_20-20-28_online-video-cutter.com.mp4

TESTING INSTRUCTIONS

  1. Manual Testing

    1. Create or open a Table chart that includes boolean columns.
    2. Add the boolean column you want to test.
    3. Open the custom conditional formatting panel and choose that column.
    4. Select the isTrue operator — cells with true should be highlighted.
    5. Select the isFalse operator — cells with false should be highlighted.
    6. Select the isNull operator — empty/null cells should be highlighted.
    7. Select the isNotNull operator — non-empty cells should be highlighted.
  2. Automated Tests:

    • Run all tests:
cd superset-frontend
npm run test
  • Run specific unit tests added in this pr:
npm run test -- getColorFormatters
npm run test -- TableChart
npm run test -- FormattingPopoverContent

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

CodeAnt-AI Description

Add boolean-aware conditional formatting to table charts

What Changed

  • Table charts now support conditional formatting on boolean columns with operators for “is true”, “is false”, “is null”, and “is not null”
  • Boolean columns appear in the conditional formatting panel with a simplified operator selector that does not require entering a target value
  • Cells representing null or empty values (including those shown as “N/A”) can now be highlighted when they match the configured condition
  • Added automated tests to cover boolean column formatting and the updated conditional formatting UI behavior

Impact

✅ Clearer true/false status in tables
✅ Easier highlighting of boolean columns
✅ Consistent styling of empty/null cells

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@edison-lhk edison-lhk marked this pull request as ready for review November 30, 2025 02:01
@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:table Related to the Table chart labels Nov 30, 2025
@SBIN2010
Copy link
Copy Markdown
Contributor

SBIN2010 commented Dec 1, 2025

Running CI 🤞

@SBIN2010
Copy link
Copy Markdown
Contributor

SBIN2010 commented Dec 1, 2025

Something is broken;
@edison-lhk could you try merging with master?

@edison-lhk edison-lhk force-pushed the feature/conditional-formatting-boolean-improvement branch from 0fa5b13 to 8fb4ca3 Compare December 1, 2025 22:50
@edison-lhk
Copy link
Copy Markdown
Contributor Author

Something is broken; @edison-lhk could you try merging with master?

Thanks! I have just rebase the current branch on the master, we can try again with the CI

@SBIN2010
Copy link
Copy Markdown
Contributor

SBIN2010 commented Dec 1, 2025

Rerunning CI 🤞

@SBIN2010 SBIN2010 added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Dec 1, 2025
@github-actions github-actions Bot added 🎪 8fb4ca3 🚦 building and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Dec 1, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 1, 2025

🎪 Showtime is building environment on GHA for 8fb4ca3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 2, 2025

🎪 Showtime deployed environment on GHA for 8fb4ca3

Environment: http://35.92.143.134:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@edison-lhk edison-lhk requested a review from SBIN2010 December 2, 2025 20:10
@SBIN2010
Copy link
Copy Markdown
Contributor

SBIN2010 commented Dec 2, 2025

Hi @edison-lhk! Something was wrong with the test environment, so I tested it locally. The only issue I saw was that the "is not null" operator wasn't fitting into the drop-down list.
Снимок экрана от 2025-12-02 23-58-25

@codeant-ai-for-open-source
Copy link
Copy Markdown
Contributor

CodeAnt AI is reviewing your PR.

@codeant-ai-for-open-source codeant-ai-for-open-source Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Dec 2, 2025
@edison-lhk
Copy link
Copy Markdown
Contributor Author

Thanks a lot @SBIN2010! I have fixed this issue and it looks like this now!
Screenshot 2025-12-02 at 5 01 08 PM

@codeant-ai-for-open-source
Copy link
Copy Markdown
Contributor

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Code Smell
    The newly added boolean comparators (IsTrue, IsFalse, IsNull, IsNotNull) conceptually do not require a targetValue, yet they still depend on the existing guard that returns () => undefined whenever operator !== Comparator.None and targetValue is undefined. Unless all configs for these operators always set a dummy targetValue, boolean conditional formatting can silently no-op, making the API fragile and harder to reason about.

  • Possible Logic Bug
    In renderOperator, when showOnlyNone is true and the column type is boolean, the function still uses booleanOperatorOptions, so the only available operator becomes is null instead of an actual "None" option. This diverges from numeric/string behavior (where Comparator.None is enforced in this mode) and may break the intended "no condition" semantics for gradient color schemes with boolean columns.

  • Behavior Change
    The render cell without color test now asserts that the N/A cell has a background color applied, which is the opposite of the original behavior and of what the test name suggests. This may indicate a silent change in how null numeric values are treated by conditional formatting (e.g., null now satisfying < 12342 and being highlighted). The reviewer should confirm whether this behavior change is intentional and either adjust the test name/description or the underlying conditional-formatting logic accordingly.

  • Type Compatibility
    The ColorFormatters type now allows getColorFromValue to receive boolean and null in addition to number | string. This may break existing implementations if their function signatures still accept only number | string (because function parameters are contravariant under strict function types). It's worth double‑checking all ColorFormatters creators and usages to ensure their handlers are updated to accept the expanded value set and that they correctly handle boolean/null at runtime.

  • Logic Coverage
    New Comparator enum members for boolean-like checks (IsTrue, IsFalse, IsNull, IsNotNull) have been added. Downstream logic that interprets comparators (e.g., conditional formatting evaluation, serialization/deserialization, and UI control options) must be updated to handle these new cases; otherwise, these operators may either be ignored or behave inconsistently across the app.

  • Possible Bug
    The new Comparator.IsNull and Comparator.IsNotNull branches only treat value === null (and for IsNotNull additionally require isBoolean(value)), which does not align with the PR description of handling "empty" vs "non-empty" cells and will not match undefined or other falsy/empty values. This may cause some visually empty cells not to be formatted as expected, especially if upstream data uses undefined for missing values or if IsNotNull is ever used on non-boolean columns.

  • Test Coverage
    The nameAndBoolean fixture defines the boolean type only via coltypes while leaving datasource.columns and rawFormData unset. The reviewer should confirm that boolean conditional formatting logic in tests does not depend on datasource metadata or form-data to infer column types; otherwise this fixture may not fully reflect real-world chart configurations.

  • UI/Layout Issue
    In the boolean branch of renderOperatorFields, a hidden targetValue field is rendered inside a Col whose span combined with the operator column exceeds the 24-column grid and still occupies layout space even though the field is hidden. This can cause misaligned or unintended layout for the operator row when formatting boolean columns.

@codeant-ai-for-open-source
Copy link
Copy Markdown
Contributor

CodeAnt AI finished reviewing your PR.

Copy link
Copy Markdown
Contributor

@SBIN2010 SBIN2010 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR @edison-lhk!

@edison-lhk
Copy link
Copy Markdown
Contributor Author

Thanks a lot @SBIN2010 for your review! And Evan @rusackas do you mind helping us to merge this PR please? Thank you

@rusackas rusackas merged commit eabb5bd into apache:master Dec 4, 2025
70 of 71 checks passed
Facyla pushed a commit to Facyla/superset-contrib that referenced this pull request Dec 16, 2025
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Jan 17, 2026
Co-authored-by: Morris <morrisho215215@gmail.com>
(cherry picked from commit eabb5bd)
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Jan 24, 2026
Co-authored-by: Morris <morrisho215215@gmail.com>
(cherry picked from commit eabb5bd)
rusackas pushed a commit that referenced this pull request Apr 17, 2026
- theming.mdx: document ECharts array property overrides (PR #37965) —
  array values like color palettes are fully supported and replaced entirely
  (not merged); adds Array Property Overrides section with color palette example
- configuring-superset.mdx: document PKCE support for database OAuth2
  (PR #37067) — add PKCE section under Custom OAuth2 with code_challenge_method
  config and when to use it
- cache.mdx: document ETag support for thumbnail/screenshot endpoints
  (PR #37663) — conditional GET with If-None-Match to avoid downloading
  unchanged images
- exploring-data.mdx: document SQL Lab UX improvements (PRs #37298, #37694,
  #37756) — treeview table browser, Ctrl+F find widget, resizable panels;
  also adds time range natural language expressions section (PR #37098)
- creating-your-first-dashboard.mdx: document Table chart features — boolean
  and categorical conditional formatting (PRs #36338, #37756), gradient toggle
  (PR #36280), HTML cell rendering with security note (PR #37685), column
  header tooltips from dataset descriptions (PR #37179), Display Controls
  modal in dashboard view (PR #36062)
- databases.json: update StarRocks supports_catalog and supports_dynamic_catalog
  to true — the engine spec (PR #37026) already implemented full catalog support
  with get_catalog_names(), get_default_catalog(), and SHOW CATALOGS; the
  committed JSON was stale and did not reflect this

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
Co-authored-by: Morris <morrisho215215@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend packages plugins 🎪 🔒 showtime-blocked size/L size:L This PR changes 100-499 lines, ignoring generated files viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants