Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Size Picker: update changelog for #45041 #45180

Merged
merged 2 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bug Fix

- `Button`: Fix RTL alignment for buttons containing an icon and text ([#44787](https://github.com/WordPress/gutenberg/pull/44787)).
- `FontSizePicker`: Fallback to font size `slug` if `name` is undefined ([#45041](https://github.com/WordPress/gutenberg/pull/45041)).

### Internal

Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,15 @@ const UnforwardedFontSizePicker = (
__( 'Currently selected font size: %s' ),
selectedOption.name
);

const headerAriaLabel = `${ __( 'Size' ) } ${ headerHint || '' }`;

return (
<Container ref={ ref } className="components-font-size-picker">
<VisuallyHidden as="legend">{ __( 'Font size' ) }</VisuallyHidden>
<Spacer>
<HStack className="components-font-size-picker__header">
<HeaderLabel>
<HeaderLabel aria-label={ headerAriaLabel }>
{ __( 'Size' ) }
{ headerHint && (
<HeaderHint className="components-font-size-picker__header__hint">
Expand Down
41 changes: 41 additions & 0 deletions packages/components/src/font-size-picker/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,47 @@ describe( 'FontSizePicker', () => {
'XL'
);
} );
it( 'should use font size `slug` for for header hint label by default', () => {
const fontSizes = [
{
name: 'Allosaurus Large',
slug: 'allosaurus-l',
size: '20rem',
},
];
render(
<FontSizePicker
fontSizes={ fontSizes }
value={ fontSizes[ 0 ].size }
__nextHasNoMarginBottom
/>
);

const largeFontSizeElement = screen.getByLabelText(
'Size Allosaurus Large(rem)'
);
expect( largeFontSizeElement ).toBeInTheDocument();
} );
it( 'should fallback to font size `slug` for header hint label if `name` is undefined', () => {
const fontSizes = [
{
slug: 'gigantosaurus',
size: '1000px',
},
];
render(
<FontSizePicker
fontSizes={ fontSizes }
value={ fontSizes[ 0 ].size }
__nextHasNoMarginBottom
/>
);

const giganticFontSizeElement = screen.getByLabelText(
'Size gigantosaurus(px)'
);
expect( giganticFontSizeElement ).toBeInTheDocument();
} );
} );
} );
} );