Skip to content

Commit

Permalink
[EuiModal] Wrapping header in H1 if a string is returned (#5494)
Browse files Browse the repository at this point in the history
* [EuiModal] Wrapping header in H1 if a string is returned
* Adding a changelog entry for PR 5494
* Refactoring children string checker to be more fault tolerant.
* Refactoring to use top level API isValidElement
* Moving changelog entry to main.
  • Loading branch information
1Copenut authored Dec 21, 2021
1 parent c4bcfe2 commit dea54f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Bug fixes**

- Fixed a `EuiDataGrid` sizing bug which didn't account for a horizontal scrollbar ([#5478](https://github.com/elastic/eui/pull/5478))
- Fixed `EuiModalHeaderTitle` to conditionally wrap title strings in an H1 ([#5494](https://github.com/elastic/eui/pull/5494))

**Deprecations**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Array [
class="euiModalHeader__title"
data-test-subj="confirmModalTitleText"
>
A confirmation modal
<h1>
A confirmation modal
</h1>
</div>
</div>
<div
Expand Down Expand Up @@ -160,7 +162,9 @@ Array [
class="euiModalHeader__title"
data-test-subj="confirmModalTitleText"
>
A confirmation modal
<h1>
A confirmation modal
</h1>
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ exports[`renders EuiModalHeaderTitle 1`] = `
class="euiModalHeader__title testClass1 testClass2"
data-test-subj="test subject string"
>
children
<h1>
children
</h1>
</div>
`;
2 changes: 1 addition & 1 deletion src/components/modal/modal_header_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EuiModalHeaderTitle: EuiModalHeaderTitleProps = ({
const classes = classnames('euiModalHeader__title', className);
return (
<div className={classes} {...rest}>
{children}
{React.isValidElement(children) ? children : <h1>{children}</h1>}
</div>
);
};

0 comments on commit dea54f0

Please sign in to comment.