Skip to content

Add toggle_label field to AnalysisCardBase for custom subtitle expansion text#5124

Open
shrutipatel31 wants to merge 2 commits intofacebook:mainfrom
shrutipatel31:export-D98738752
Open

Add toggle_label field to AnalysisCardBase for custom subtitle expansion text#5124
shrutipatel31 wants to merge 2 commits intofacebook:mainfrom
shrutipatel31:export-D98738752

Conversation

@shrutipatel31
Copy link
Copy Markdown
Contributor

Summary:
Adds a serializable toggle_label: str field to AnalysisCardBase that allows
analyses to customize the subtitle expand/collapse toggle button text.

When non-empty, toggle_label replaces the default "See more" text with
a context-specific label (e.g., "Expand to see annotated parameters.").
The field is persisted to both SQA and JSON storage backends, and used by
the notebook HTML template for rendering.

Changes:

  • Add toggle_label field + constructor param (default "") to AnalysisCardBase
  • Update notebook _to_html() to use self.toggle_label or "See more"
  • Add toggle_label nullable column to SQAAnalysisCard
  • Update SQA encoder/decoder (all 8 card-type callsites)
  • Update JSON encoder for both card and group dicts
  • Unit tests

Differential Revision: D98738752

Summary:

Matches the web UI change from D97406631 for notebook (Jupyter/Bento) rendering of Ax analysis cards.

**Before**: Subtitles were hidden behind a clickable <details>/<summary> element with an info icon - users had to click to reveal the subtitle text.

**After**: Subtitles are now shown as visible, secondary-styled text directly beneath the title, line-clamped to a single line. A "See more"/"See less" toggle appears automatically when the subtitle text overflows, allowing users to expand and collapse the full text.

Key changes to html_card_template in analysis_card.py:

- Replaced <details>/<summary> with always-visible <p class="card-subtitle"> using CSS -webkit-line-clamp: 2
- Added a "See more"/"See less" <button> toggle that is shown only when the subtitle is actually clamped (detected via scrollHeight > clientHeight in a requestAnimationFrame callback)
- The inline script uses `document.currentScript.previousElementSibling` to locate its sibling card element and querySelector to find the subtitle and toggle within it, avoiding the need for unique DOM IDs or any Python-side bookkeeping
- Removed the info icon CSS (content: "ℹ️") and hover-to-reveal interaction

Differential Revision: D98690381
…ion text

Summary:
Adds a serializable `toggle_label: str` field to `AnalysisCardBase` that allows
analyses to customize the subtitle expand/collapse toggle button text.

When non-empty, `toggle_label` replaces the default "See more" text with
a context-specific label (e.g., "Expand to see annotated parameters.").
The field is persisted to both SQA and JSON storage backends, and used by
the notebook HTML template for rendering.

Changes:
- Add `toggle_label` field + constructor param (default "") to AnalysisCardBase
- Update notebook `_to_html()` to use `self.toggle_label or "See more"`
- Add `toggle_label` nullable column to SQAAnalysisCard
- Update SQA encoder/decoder (all 8 card-type callsites)
- Update JSON encoder for both card and group dicts
- Unit tests

Differential Revision: D98738752
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 2, 2026

@shrutipatel31 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98738752.

@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 2, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.41%. Comparing base (bdcfdbe) to head (8fca009).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5124   +/-   ##
=======================================
  Coverage   96.40%   96.41%           
=======================================
  Files         613      613           
  Lines       68142    68161   +19     
=======================================
+ Hits        65694    65717   +23     
+ Misses       2448     2444    -4     

☔ View full report in Codecov by Sentry.
📢 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.

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

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants