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

Block Inspector: Avoid advanced panel only settings tab #47474

Merged
merged 3 commits into from
Jan 30, 2023
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
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