Skip to content

Commit

Permalink
Block Inspector: Avoid advanced panel only settings tab (#47474)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw authored Jan 30, 2023
1 parent 6d41283 commit 7980013
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ export default function useInspectorControlsTabs( blockName ) {
tabs.push( TAB_STYLES );
}

// Settings Tab: If there are any fills for the general InspectorControls
// or Advanced Controls slot, then add this tab.
// Settings Tab: If we don't already have multiple tabs to display
// (i.e. both list view and styles), check only the default and position
// InspectorControls slots. If we have multiple tabs, we'll need to check
// the advanced controls slot as well to ensure they are rendered.
const advancedFills =
useSlotFills( InspectorAdvancedControls.slotName ) || [];

const settingsFills = [
...( useSlotFills( defaultGroup.Slot.__unstableName ) || [] ),
...( useSlotFills( positionGroup.Slot.__unstableName ) || [] ),
...( useSlotFills( InspectorAdvancedControls.slotName ) || [] ),
...( tabs.length > 1 ? advancedFills : [] ),
];

if ( settingsFills.length ) {
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/specs/editor/blocks/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ test.describe( 'Table', () => {
} ) => {
await editor.insertBlock( { name: 'core/table' } );
await editor.openDocumentSettingsSidebar();
await page.click(
`role=region[name="Editor settings"i] >> role=tab[name="Settings"i]`
);

const headerSwitch = page.locator(
'role=checkbox[name="Header section"i]'
Expand All @@ -96,6 +93,9 @@ test.describe( 'Table', () => {
await page.click( 'role=button[name="Create Table"i]' );

// Expect the header and footer switches to be present now that the table has been created.
await page.click(
`role=region[name="Editor settings"i] >> role=tab[name="Settings"i]`
);
await expect( headerSwitch ).toBeVisible();
await expect( footerSwitch ).toBeVisible();

Expand Down Expand Up @@ -135,9 +135,6 @@ test.describe( 'Table', () => {
} ) => {
await editor.insertBlock( { name: 'core/table' } );
await editor.openDocumentSettingsSidebar();
await page.click(
`role=region[name="Editor settings"i] >> role=tab[name="Settings"i]`
);

// Create the table.
await page.click( 'role=button[name="Create Table"i]' );
Expand Down Expand Up @@ -211,14 +208,14 @@ test.describe( 'Table', () => {
} ) => {
await editor.insertBlock( { name: 'core/table' } );
await editor.openDocumentSettingsSidebar();
await page.click(
`role=region[name="Editor settings"i] >> role=tab[name="Settings"i]`
);

// Create the table.
await page.click( 'role=button[name="Create Table"i]' );

// Enable fixed width as it exacerbates the amount of empty space around the RichText.
await page.click(
`role=region[name="Editor settings"i] >> role=tab[name="Settings"i]`
);
await page
.locator( 'role=checkbox[name="Fixed width table cells"i]' )
.check();
Expand Down
10 changes: 1 addition & 9 deletions test/e2e/specs/site-editor/push-to-global-styles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ test.describe( 'Push to Global Styles button', () => {
page.getByRole( 'button', { name: 'Uppercase' } )
).toHaveAttribute( 'aria-pressed', 'false' );

// Go to block settings, select inner tab, and open the Advanced panel
// Go to block settings and open the Advanced panel
await page.getByRole( 'button', { name: 'Settings' } ).click();
await page.getByRole( 'tab', { name: 'Settings' } ).click();
await page.getByRole( 'button', { name: 'Advanced' } ).click();

// Push button should be disabled
Expand All @@ -54,16 +53,9 @@ test.describe( 'Push to Global Styles button', () => {
} )
).toBeDisabled();

// Switch back to the Styles inspector tab to check typography style
await page.getByRole( 'tab', { name: 'Styles' } ).click();

// Make the Heading block uppercase
await page.getByRole( 'button', { name: 'Uppercase' } ).click();

// Switch back to the Settings inspector tab to check for enabled button
await page.getByRole( 'tab', { name: 'Settings' } ).click();
await page.getByRole( 'button', { name: 'Advanced' } ).click();

// Push button should now be enabled
await expect(
page.getByRole( 'button', {
Expand Down

1 comment on commit 7980013

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 7980013.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4040581801
📝 Reported issues:

Please sign in to comment.