Repository navigation
Conversation
Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
…g it Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
🦋 Changeset detectedLatest commit: 61633ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
Collapsed alerts stay capped by maxHeight. Expanded alerts lift that cap, grow to the parent, and scroll the text when it still overflows. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
The expanded alert now fills its container, so the expanded captures are taller and show the text scrollbar. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
| min-height: 0; | ||
| max-height: none; | ||
| flex: 1 1 auto; | ||
| } |
There was a problem hiding this comment.
Expanding drops the height cap
High Severity
Expanding applies alert_expanded, which sets max-height to none. If the parent has no definite height, height: 100% and flex: 1 1 auto do nothing, so the alert grows with the text. Overflow then measures as false, the Show less toggle unmounts, and the expanded layout cannot be collapsed.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ca3b277. Configure here.
The text column was only as wide as the message, so the scrollbar sat in the middle of the alert. It now fills the remaining width. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
The expanded story play only opens the alert. Height, scroll, and width stay in the Playwright test. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Storybook Preview Deployed✅ Preview URL: https://click-7mu0xyfyv-clickhouse.vercel.app Built from commit: |
Chromatic Storybook
Built from commit: Statuses as of the end of the run. The build link shows the live review state. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 61633ee. Configure here.
| > | ||
| {isExpanded ? collapseLabel : expandLabel} | ||
| </button> | ||
| )} |
There was a problem hiding this comment.
Show less vanishes after expand
High Severity
The Show more control is rendered only while isOverflowing is true, including after expand. Expanding lifts max-height and sets height: 100%, so the text often fits in the new layout. The toggle then unmounts, Show less is gone, and keyboard focus on that button is dropped. For the common maxHeight={240} usage without a sized parent, the alert grows with the message and cannot be collapsed, which brings back the layout jump this feature is meant to prevent.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 61633ee. Configure here.
XOP
left a comment
There was a problem hiding this comment.
Please consider the updates.
| } | ||
|
|
||
| /* Expanded lifts the collapsed cap and fills the parent. The text then scrolls. */ | ||
| .alert_max-height.alert_expanded { |
There was a problem hiding this comment.
Can we instead go with max-height: 100% instead of height: 100%; flex: 1 1 auto while expanded?
what happens - after Show more activation, the alert grows until nothing overflows, so the toggle unmounts in the same click and focus falls to body.
Note that test would also require changes.
| } | ||
|
|
||
| /* stylelint-disable plugin/no-unsupported-browser-features, property-no-vendor-prefix -- Chrome below 120 and Safari below 15.4 only know the prefixed mask, and the build has no autoprefixer */ | ||
| .alert_max-height .alert__text { |
| ref={textRef} | ||
| id={hasMaxHeight ? textId : undefined} | ||
| tabIndex={isScrollable ? 0 : undefined} | ||
| role={isScrollable && hasTitle ? 'region' : undefined} |
There was a problem hiding this comment.
Without a title the expanded text gets tabIndex=0 but no role or name.
Could it always be role="region", named by the title or by a fallback label when there is none?
| /** When true, string `text` keeps `\n` line breaks. Defaults to `false`. */ | ||
| preserveLineBreaks?: boolean; | ||
| /** Caps the collapsed alert, toggle included. Expanded, the cap lifts and the alert fills its container; the text scrolls if it still overflows. A number is px; a string is any CSS length, e.g. `'12lh'` or `'100%'`. */ | ||
| maxHeight?: number | string; |
There was a problem hiding this comment.
Every other maxHeight / maxWidth in the library is string only. Can this be string too?
|
|
||
| const rootStyle = useMemo( | ||
| () => | ||
| hasMaxHeight |
There was a problem hiding this comment.
I think we need a reasonable lower bound on maxHeight. Otherwise, we'll end up with some weird collapsed states:




Description
A long error in an alert pushes the page under it. Query failures are the usual case: the message is many lines, and the reader still needs all of it.
#1277 made those line breaks visible. The review on that PR asked for the next step on the same component: cap the alert, and let the reader open the rest in place. Each app should not have to build its own Show more box.
This is that follow-up (CUI-336).
Alertis unchanged until you passmaxHeight.Alert, because the need is a long message in an alert. Happy to revisit that.maxHeightis a number (px) or any CSS length ('12lh','100%'). The cap includes the toggle.onExpandedChangefires only whenmaxHeightis set.expandLabelandcollapseLabeldefault to Show more and Show less.WarningAlert,DangerAlert,InfoAlert, andSuccessAlertpass the props through.The expanded state stays inside the alert. Remount with
keyto reset it. There is no controlledexpandedprop, and the text does not open in a modal.Links and tickets
Checklist
minor.maxHeightis set. Collapsed snapshots are unchanged. The four expanded snapshots were regenerated because the expanded alert now fills its container.Contribution
buildandbuild-storybookwork locallyAccessibility
<button>(Enter / Space), and focus stays on it after both actions. While expanded and scrollable, the text area is focusable, so arrow keys scroll it. Tabbing onto a link inside clipped text expands the alert. Esc doesn't apply.aria-expandedandaria-controls. When a title exists, the scroll region isrole="region", named by the title.--click-global-color-outline-default. The fade is removed in forced-colors mode. The text toggle is under 24 px tall and relies on the WCAG 2.5.8 spacing exception (it sits alone on its row).WCAG 2.2 criteria checked: 1.4.3 Contrast (the toggle inherits the alert text colour), 2.1.1 Keyboard, 2.4.3 Focus Order, 2.4.7 Focus Visible, 2.5.3 Label in Name, 4.1.2 Name, Role, Value. In the Storybook Accessibility panel, axe shows no new violations on the new stories. The existing colour-contrast findings on info-state alerts also appear on the current
StateInfostory. Not tested with a real screen reader.Screencast
Collapsed, the alert stays short. Expanded, it uses the space the parent already has and the message scrolls. Show less returns to the short height.
Note
Low Risk
Additive, opt-in API on a display component; existing alerts unchanged. Risk is mainly layout/interaction edge cases around dynamic height and observer lifecycle, mitigated by extensive tests.
Reviewed by Cursor Bugbot for commit 61633ee. Bugbot is set up for automated code reviews on this repo. Configure here.