diff --git a/client/components/formatted-header/README.md b/client/components/formatted-header/README.md index 29f294d6e49d92..dd270f41b5b71e 100644 --- a/client/components/formatted-header/README.md +++ b/client/components/formatted-header/README.md @@ -22,3 +22,4 @@ function render() { - `subHeaderText` (`node`) - Sub header text (optional) - `compactOnMobile` (`bool`) - Display a compact header on small screens (optional) - `isSecondary` (`bool`) - Use the H2 element instead of the H1 (optional) +- `disablePreventWidows` (`bool`) - Disable the default behavior of inserting non-breaking space to prevent dangling words. diff --git a/client/components/formatted-header/index.tsx b/client/components/formatted-header/index.tsx index 3adebe866cbd16..ae2ae7f2dd5e22 100644 --- a/client/components/formatted-header/index.tsx +++ b/client/components/formatted-header/index.tsx @@ -18,6 +18,7 @@ interface Props extends PropsWithChildren { subHeaderAs?: ElementType; subHeaderText?: ReactNode; tooltipText?: ReactNode; + disablePreventWidows?: boolean; } const FormattedHeader: FC< Props > = ( { @@ -35,6 +36,7 @@ const FormattedHeader: FC< Props > = ( { subHeaderAs: SubHeaderAs = 'p', subHeaderText, tooltipText, + disablePreventWidows, } ) => { const classes = clsx( 'formatted-header', className, { 'is-without-subhead': ! subHeaderText, @@ -54,24 +56,27 @@ const FormattedHeader: FC< Props > = ( { ); + const formattedHeaderText = disablePreventWidows ? headerText : preventWidows( headerText, 2 ); + const formattedSubHeaderText = disablePreventWidows + ? subHeaderText + : preventWidows( subHeaderText, 2 ); + return (
{ ! isSecondary && (

- { preventWidows( headerText, 2 ) } { tooltip } + { formattedHeaderText } { tooltip }

) } { isSecondary && (

- { preventWidows( headerText, 2 ) } { tooltip } + { formattedHeaderText } { tooltip }

) } { screenReader &&

{ screenReader }

} - { subHeaderText && ( - - { preventWidows( subHeaderText, 2 ) } - + { formattedSubHeaderText && ( + { formattedSubHeaderText } ) }
{ children } diff --git a/client/signup/step-wrapper/index.jsx b/client/signup/step-wrapper/index.jsx index 6d13637678ba38..8dff7913ac5ca4 100644 --- a/client/signup/step-wrapper/index.jsx +++ b/client/signup/step-wrapper/index.jsx @@ -233,6 +233,7 @@ class StepWrapper extends Component { headerText={ this.headerText() } subHeaderText={ this.subHeaderText() } align={ align } + disablePreventWidows /> { headerImageUrl && (
diff --git a/client/signup/step-wrapper/style.scss b/client/signup/step-wrapper/style.scss index 3211868ba9b1cd..497e55db9200b4 100644 --- a/client/signup/step-wrapper/style.scss +++ b/client/signup/step-wrapper/style.scss @@ -8,6 +8,7 @@ .formatted-header { flex-grow: 1; + text-wrap: pretty; } @include breakpoint-deprecated( "<660px" ) {