Repository navigation
feat(Alert): add preserveLineBreaks prop - #1277
Conversation
Render `\n` in string `text` and `title` with pre-wrap, and wrap long unbroken tokens. ReactNode content is unchanged. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
🦋 Changeset detectedLatest commit: 41b78b9 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 |
|
|
Keep default Alert rendering unchanged. String text and title preserve newlines only when preserveLineBreaks is true. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Show Alexey's SQL Console S3 signatures error with preserveLineBreaks off and on so the PR before/after matches the original control-plane case. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Use multilineS3SignaturesError for the multi-line S3 signatures error (SQL-2580 / CUI-335). The rendered message text is unchanged. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
preserveLineBreaks sets pre-wrap only on string text. A title stays one line, including when the string contains a newline. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
XOP
left a comment
There was a problem hiding this comment.
we can proceed with this change and add extra Text.wrap mode later for convenience
Restore the original title markup. The opt-in class only sets white-space: pre-wrap. Long tokens still wrap through the existing word-break on the text wrapper. Co-authored-by: Fábio Neves <fabio.neves@clickhouse.com>
Storybook Preview Deployed✅ Preview URL: https://click-kg1elalmo-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. |
Description
Add an opt-in
preserveLineBreaksprop onAlert. When it is true, stringtextuseswhite-space: pre-wrapandoverflow-wrap: anywhere. It defaults tofalse. Default Alert rendering matchesmain.The title stays one line. The prop does not add a class on the title.
WarningAlert,DangerAlert,InfoAlert, andSuccessAlertpass the prop through.The style applies only to string
text. ReactNodetextdoes not change, becausewhite-spaceinherits.Why
preserveLineBreaksThe name states the user-facing goal: keep
\nas line breaks in the text. It is not a CSS identifier such aspreWrap. It is notpreserveWhitespace, which would claim consecutive spaces as the feature. The overflow wrap for long tokens is a companion to that line-break opt-in.Opt-in decision
preserveLineBreaksdefaults tofalse. Existing alerts keep collapsed whitespace. Consumers that pass error strings with\nset the prop.The title does not opt in. A heading stays one line.
Control-plane follow-up: pass
preserveLineBreaksonWarningAlertinErrorBox.tsxand drop theQueryErrorAlertstyled override.Links and tickets
Good to know
Multiline textstory snapshot changed on purpose. The title string still contains\n, and it now renders as one line. The text keeps its line breaks.CollapsedNewlinesshows the default.MultilineTextandLongUnbrokenTokensetpreserveLineBreaks. Playground has a boolean control.Checklist
Contribution
buildandbuild-storybookwork locallyAccessibility
aria-label="close". No new icon-only controls.Screenshots
Default (
preserveLineBreaks={false}):\ncollapses.Opt-in (
preserveLineBreaks={true}): line breaks stay in the text.Opt-in long unbroken token wrapping:
Note
Low Risk
Opt-in display behavior on a UI component with default unchanged; no auth, data, or API surface changes.
Reviewed by Cursor Bugbot for commit 41b78b9. Bugbot is set up for automated code reviews on this repo. Configure here.