Skip to content

Commit e123e7a

Browse files
committed
update toggle custom size label
1 parent 0961ee0 commit e123e7a

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

packages/components/src/font-size-picker/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ function FontSizePicker(
125125
{ ! disableCustomFontSizes && (
126126
<FlexItem>
127127
<Button
128-
label={ __( 'Toggle custom size display' ) }
128+
label={
129+
showCustomValueControl
130+
? __( 'Use size preset' )
131+
: __( 'Set custom size' )
132+
}
129133
showTooltip={ false }
130134
icon={ settings }
131135
onClick={ () => {

packages/components/src/font-size-picker/test/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ const getUnitSelect = () =>
1313
const getUnitLabel = () =>
1414
document.body.querySelector( '.components-unit-control__unit-label' );
1515

16-
const toggleCustomInput = () => {
17-
const toggleCustom = screen.getByLabelText( 'Toggle custom size display', {
18-
selector: 'button',
19-
} );
16+
const toggleCustomInput = ( showCustomInput ) => {
17+
const label = showCustomInput ? 'Set custom size' : 'Use size preset';
18+
const toggleCustom = screen.getByLabelText( label, { selector: 'button' } );
2019
fireEvent.click( toggleCustom );
2120
};
2221

@@ -91,7 +90,7 @@ describe( 'FontSizePicker', () => {
9190
/>
9291
);
9392

94-
toggleCustomInput();
93+
toggleCustomInput( true );
9594
const unitSelect = getUnitSelect();
9695
const unitLabel = getUnitLabel();
9796
const input = screen.getByLabelText( 'Custom', {
@@ -127,7 +126,7 @@ describe( 'FontSizePicker', () => {
127126
/>
128127
);
129128

130-
toggleCustomInput();
129+
toggleCustomInput( true );
131130
const unitSelect = getUnitSelect();
132131
const unitLabel = getUnitLabel();
133132
const input = screen.getByLabelText( 'Custom', {

packages/e2e-tests/specs/editor/various/font-size-picker.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const clickFontSizeButtonByLabel = async ( label ) => {
2929
};
3030

3131
// Clicks the button to toggle between custom size input and the control for the presets.
32-
const toggleCustomInput = async () => {
32+
const toggleCustomInput = async ( showCustomInput ) => {
33+
const label = showCustomInput ? 'Set custom size' : 'Use size preset';
3334
const toggleButton = await page.waitForXPath(
34-
"//button[@aria-label='Toggle custom size display']"
35+
`//button[@aria-label='${ label }']`
3536
);
3637
return toggleButton.click();
3738
};
@@ -68,7 +69,7 @@ describe( 'Font Size Picker', () => {
6869
await clickBlockAppender();
6970
await page.keyboard.type( 'Paragraph to be made "small"' );
7071

71-
await toggleCustomInput();
72+
await toggleCustomInput( true );
7273
await clickCustomInput();
7374
// This should be the "small" font-size of the editor defaults.
7475
await page.keyboard.type( '13' );
@@ -84,7 +85,7 @@ describe( 'Font Size Picker', () => {
8485
await clickBlockAppender();
8586
await page.keyboard.type( 'Paragraph to be made "small"' );
8687

87-
await toggleCustomInput();
88+
await toggleCustomInput( true );
8889
await clickCustomInput();
8990
await page.keyboard.type( '23' );
9091
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
@@ -102,7 +103,7 @@ describe( 'Font Size Picker', () => {
102103
);
103104

104105
await clickFontSizeButtonByLabel( 'Small' );
105-
await toggleCustomInput();
106+
await toggleCustomInput( true );
106107

107108
await page.keyboard.press( 'Tab' );
108109
await page.keyboard.press( 'Tab' );
@@ -124,7 +125,7 @@ describe( 'Font Size Picker', () => {
124125
);
125126

126127
await clickFontSizeButtonByLabel( 'Small' );
127-
await toggleCustomInput();
128+
await toggleCustomInput( true );
128129
await clickCustomInput();
129130
await pressKeyWithModifier( 'primary', 'A' );
130131
await page.keyboard.press( 'Backspace' );
@@ -145,7 +146,7 @@ describe( 'Font Size Picker', () => {
145146
await clickBlockAppender();
146147
await page.keyboard.type( 'Paragraph to be made "small"' );
147148

148-
await toggleCustomInput();
149+
await toggleCustomInput( true );
149150
await clickCustomInput();
150151
await page.keyboard.type( '23' );
151152
await page.keyboard.press( 'Backspace' );

0 commit comments

Comments
 (0)