Skip to content

Commit

Permalink
Fix code review recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Oct 20, 2023
1 parent 6994f94 commit 10cddb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 4 additions & 1 deletion packages/interactivity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bug Fix

- Update the title when using enhanced pagination. ([#55446](https://github.com/WordPress/gutenberg/pull/55446))

## 2.5.0 (2023-10-18)

## 2.4.0 (2023-10-05)
Expand All @@ -16,7 +20,6 @@

- Remove `role` attribute when set to `null` in `data-wp-bind`. ([#54608](https://github.com/WordPress/gutenberg/pull/54608))
- Add `timeout` option to `navigate()`, with a default value of `10000` milliseconds. ([#54474](https://github.com/WordPress/gutenberg/pull/54474))
- Update the title when using enhanced pagination. ([#55446](https://github.com/WordPress/gutenberg/pull/55446))

## 2.2.0 (2023-08-31)

Expand Down
8 changes: 4 additions & 4 deletions packages/interactivity/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const regionsToVdom = ( dom ) => {
const id = region.getAttribute( attrName );
regions[ id ] = toVdom( region );
} );
const title = dom.querySelector( 'title' ).innerText || null;
const title = dom.querySelector( 'title' )?.innerText;
return { regions, title };
};

Expand All @@ -75,10 +75,10 @@ const renderRegions = ( page ) => {
const id = region.getAttribute( attrName );
const fragment = getRegionRootFragment( region );
render( page.regions[ id ], fragment );
if ( page.title ) {
document.title = page.title;
}
} );
if ( page.title ) {
document.title = page.title;
}
};

// Variable to store the current navigation.
Expand Down
11 changes: 4 additions & 7 deletions test/e2e/specs/interactivity/router-regions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,16 @@ test.describe( 'Router regions', () => {
await expect( nestedRegionSsr ).toHaveText( 'content from page 1' );
} );

test( 'Page title is updated', async ( { page } ) => {
expect( await page.title() ).toBe(
test( 'Page title is updated 2', async ( { page } ) => {
await expect( page ).toHaveTitle(
'router regions – page 1 – gutenberg'
);
await page.getByTestId( 'next' ).click();
await page.waitForFunction(
() => document.title === 'router regions – page 2 – gutenberg'
);
expect( await page.title() ).toBe(
await expect( page ).toHaveTitle(
'router regions – page 2 – gutenberg'
);
await page.getByTestId( 'back' ).click();
expect( await page.title() ).toBe(
await expect( page ).toHaveTitle(
'router regions – page 1 – gutenberg'
);
} );
Expand Down

0 comments on commit 10cddb4

Please sign in to comment.