Skip to content

Commit

Permalink
prep build 10/17
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Oct 17, 2022
2 parents 54ca5df + 6bc1ec5 commit 63f98bf
Show file tree
Hide file tree
Showing 30 changed files with 637 additions and 519 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ module.exports = {
'negate',
'noop',
'nth',
'omitBy',
'once',
'overEvery',
'partial',
Expand Down Expand Up @@ -319,6 +320,11 @@ module.exports = {
excludedFiles: [ 'test/e2e/**/*.js' ],
extends: [ 'plugin:@wordpress/eslint-plugin/test-unit' ],
},
{
files: [ '**/test/**/*.js' ],
excludedFiles: [ '**/*.@(android|ios|native).js' ],
extends: [ 'plugin:jest-dom/recommended' ],
},
{
files: [ 'packages/e2e-test*/**/*.js' ],
excludedFiles: [ 'packages/e2e-test-utils-playwright/**/*.js' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ registerBlockType( 'gutenberg-examples/example-dynamic', {

{% end %}

Note that this code uses the `wp-server-side-render` package but not `wp-data`. Make sure to update the dependencies in the PHP code. You can use wp-scripts to automatically build dependencies (see the [gutenberg-examples repo](https://github.com/WordPress/gutenberg-examples/tree/HEAD/01-basic-esnext) for PHP code setup).
Note that this code uses the `wp-server-side-render` package but not `wp-data`. Make sure to update the dependencies in the PHP code. You can use wp-scripts to automatically build dependencies (see the [gutenberg-examples repo](https://github.com/WordPress/gutenberg-examples/tree/trunk/blocks-jsx/01-basic-esnext) for PHP code setup).
14 changes: 14 additions & 0 deletions docs/reference-guides/block-api/block-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ supports: {
}
```

## ariaLabel

- Type: `boolean`
- Default value: `false`

ARIA-labels let you define an accessible label for elements. This property allows enabling the definition of an aria-label for the block, without exposing a UI field.

```js
supports: {
// Add the support for aria label.
ariaLabel: true
}
```

## className

- Type: `boolean`
Expand Down
1 change: 1 addition & 0 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function gutenberg_reregister_core_block_types() {
'heading',
'html',
'list',
'list-item',
'media-text',
'missing',
'more',
Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"eslint-import-resolver-node": "0.3.4",
"eslint-plugin-eslint-comments": "3.1.2",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jest-dom": "4.0.2",
"eslint-plugin-playwright": "0.8.0",
"eslint-plugin-ssr-friendly": "1.0.6",
"execa": "4.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/a11y/src/test/clear.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe( 'clear', () => {
document.body.appendChild( container2 );

clear();
expect( container1 ).toHaveTextContent( '' );
expect( container2 ).toHaveTextContent( '' );
expect( container1 ).toBeEmptyDOMElement();
expect( container2 ).toBeEmptyDOMElement();
} );
} );
6 changes: 3 additions & 3 deletions packages/a11y/src/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe( 'speak', () => {
it( 'should set the textcontent of the polite aria-live region', () => {
speak( 'default message' );
expect( containerPolite ).toHaveTextContent( 'default message' );
expect( containerAssertive ).toHaveTextContent( '' );
expect( containerAssertive ).toBeEmptyDOMElement();
expect( clear ).toHaveBeenCalled();
expect( filterMessage ).toHaveBeenCalledWith( 'default message' );
} );
Expand All @@ -52,7 +52,7 @@ describe( 'speak', () => {
describe( 'in assertive mode', () => {
it( 'should set the textcontent of the assertive aria-live region', () => {
speak( 'assertive message', 'assertive' );
expect( containerPolite ).toHaveTextContent( '' );
expect( containerPolite ).toBeEmptyDOMElement();
expect( containerAssertive ).toHaveTextContent(
'assertive message'
);
Expand All @@ -63,7 +63,7 @@ describe( 'speak', () => {
it( 'should set the textcontent of the polite aria-live region', () => {
speak( 'polite message', 'polite' );
expect( containerPolite ).toHaveTextContent( 'polite message' );
expect( containerAssertive ).toHaveTextContent( '' );
expect( containerAssertive ).toBeEmptyDOMElement();
} );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default function SpacingInputControl( {
<RangeControl
value={ customRangeValue }
min={ 0 }
max={ 100 }
max={ 300 }
withInputField={ false }
onChange={ handleCustomValueSliderChange }
className="components-spacing-sizes-control__custom-value-range"
Expand Down
14 changes: 7 additions & 7 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { reduce, omit, mapValues, isEqual, isEmpty, omitBy } from 'lodash';
import { reduce, omit, mapValues, isEqual, isEmpty } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -417,15 +417,15 @@ const withBlockTree =
break;
}
case 'SAVE_REUSABLE_BLOCK_SUCCESS': {
const updatedBlockUids = Object.keys(
omitBy( newState.attributes, ( attributes, clientId ) => {
const updatedBlockUids = Object.entries( newState.attributes )
.filter( ( [ clientId, attributes ] ) => {
return (
newState.byClientId[ clientId ].name !==
'core/block' ||
attributes.ref !== action.updatedId
newState.byClientId[ clientId ].name ===
'core/block' &&
attributes.ref === action.updatedId
);
} )
);
.map( ( [ clientId ] ) => clientId );

newState.tree = updateParentInnerBlocksInTree(
newState,
Expand Down
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Bug Fix

- `FontSizePicker`: Ensure that fluid font size presets appear correctly in the UI controls ([#44791](https://github.com/WordPress/gutenberg/pull/44791)).
- `Navigator`: prevent partially hiding focus ring styles, by removing unnecessary overflow rules on `NavigatorScreen` ([#44973](https://github.com/WordPress/gutenberg/pull/44973)).
- `Navigator`: restore focus only once per location ([#44972](https://github.com/WordPress/gutenberg/pull/44972)).

### Documentation

Expand All @@ -15,6 +17,7 @@
- `Modal`: Convert to TypeScript ([#42949](https://github.com/WordPress/gutenberg/pull/42949)).
- `Sandbox`: Use `toString` to create observe and resize script string ([#42872](https://github.com/WordPress/gutenberg/pull/42872)).
- `Navigator`: refactor unit tests to TypeScript and to `user-event` ([#44970](https://github.com/WordPress/gutenberg/pull/44970)).
- `Navigator`: Refactor Storybook code to TypeScript and controls ([#44979](https://github.com/WordPress/gutenberg/pull/44979)).

## 21.2.0 (2022-10-05)

Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/navigator/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as NavigatorProvider } from './navigator-provider';
export { default as NavigatorScreen } from './navigator-screen';
export { default as NavigatorButton } from './navigator-button';
export { default as NavigatorBackButton } from './navigator-back-button';
export { NavigatorProvider } from './navigator-provider';
export { NavigatorScreen } from './navigator-screen';
export { NavigatorButton } from './navigator-button';
export { NavigatorBackButton } from './navigator-back-button';
export { default as useNavigator } from './use-navigator';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { View } from '../../view';
import { useNavigatorBackButton } from './hook';
import type { NavigatorBackButtonProps } from '../types';

function NavigatorBackButton(
function UnconnectedNavigatorBackButton(
props: WordPressComponentProps< NavigatorBackButtonProps, 'button' >,
forwardedRef: ForwardedRef< any >
) {
Expand Down Expand Up @@ -54,9 +54,9 @@ function NavigatorBackButton(
* );
* ```
*/
const ConnectedNavigatorBackButton = contextConnect(
NavigatorBackButton,
export const NavigatorBackButton = contextConnect(
UnconnectedNavigatorBackButton,
'NavigatorBackButton'
);

export default ConnectedNavigatorBackButton;
export default NavigatorBackButton;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './component';
export { default as NavigatorBackButton } from './component';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { View } from '../../view';
import { useNavigatorButton } from './hook';
import type { NavigatorButtonProps } from '../types';

function NavigatorButton(
function UnconnectedNavigatorButton(
props: WordPressComponentProps< NavigatorButtonProps, 'button' >,
forwardedRef: ForwardedRef< any >
) {
Expand Down Expand Up @@ -53,9 +53,9 @@ function NavigatorButton(
* );
* ```
*/
const ConnectedNavigatorButton = contextConnect(
NavigatorButton,
export const NavigatorButton = contextConnect(
UnconnectedNavigatorButton,
'NavigatorButton'
);

export default ConnectedNavigatorButton;
export default NavigatorButton;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './component';
export { default as NavigatorButton } from './component';
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type {
NavigatorContext as NavigatorContextType,
} from '../types';

function NavigatorProvider(
function UnconnectedNavigatorProvider(
props: WordPressComponentProps< NavigatorProviderProps, 'div' >,
forwardedRef: ForwardedRef< any >
) {
Expand All @@ -49,6 +49,7 @@ function NavigatorProvider(
...options,
path,
isBack: false,
hasRestoredFocus: false,
},
] );
},
Expand All @@ -62,6 +63,7 @@ function NavigatorProvider(
{
...locationHistory[ locationHistory.length - 2 ],
isBack: true,
hasRestoredFocus: false,
},
] );
}
Expand Down Expand Up @@ -129,9 +131,9 @@ function NavigatorProvider(
* );
* ```
*/
const ConnectedNavigatorProvider = contextConnect(
NavigatorProvider,
export const NavigatorProvider = contextConnect(
UnconnectedNavigatorProvider,
'NavigatorProvider'
);

export default ConnectedNavigatorProvider;
export default NavigatorProvider;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './component';
export { default as NavigatorProvider } from './component';
23 changes: 17 additions & 6 deletions packages/components/src/navigator/navigator-screen/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ type Props = Omit<
keyof MotionProps
>;

function NavigatorScreen( props: Props, forwardedRef: ForwardedRef< any > ) {
function UnconnectedNavigatorScreen(
props: Props,
forwardedRef: ForwardedRef< any >
) {
const { children, className, path, ...otherProps } = useContextSystem(
props,
'NavigatorScreen'
Expand All @@ -62,14 +65,20 @@ function NavigatorScreen( props: Props, forwardedRef: ForwardedRef< any > ) {
// - if the current location is not the initial one (to avoid moving focus on page load)
// - when the screen becomes visible
// - if the wrapper ref has been assigned
if ( isInitialLocation || ! isMatch || ! wrapperRef.current ) {
// - if focus hasn't already been restored for the current location
if (
isInitialLocation ||
! isMatch ||
! wrapperRef.current ||
location.hasRestoredFocus
) {
return;
}

const activeElement = wrapperRef.current.ownerDocument.activeElement;

// If an element is already focused within the wrapper do not focus the
// element. This prevents inputs or buttons from losing focus unecessarily.
// element. This prevents inputs or buttons from losing focus unnecessarily.
if ( wrapperRef.current.contains( activeElement ) ) {
return;
}
Expand All @@ -93,10 +102,12 @@ function NavigatorScreen( props: Props, forwardedRef: ForwardedRef< any > ) {
elementToFocus = firstTabbable ?? wrapperRef.current;
}

location.hasRestoredFocus = true;
elementToFocus.focus();
}, [
isInitialLocation,
isMatch,
location.hasRestoredFocus,
location.isBack,
previousLocation?.focusTargetSelector,
] );
Expand Down Expand Up @@ -200,9 +211,9 @@ function NavigatorScreen( props: Props, forwardedRef: ForwardedRef< any > ) {
* );
* ```
*/
const ConnectedNavigatorScreen = contextConnect(
NavigatorScreen,
export const NavigatorScreen = contextConnect(
UnconnectedNavigatorScreen,
'NavigatorScreen'
);

export default ConnectedNavigatorScreen;
export default NavigatorScreen;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './component';
export { default as NavigatorScreen } from './component';
Loading

0 comments on commit 63f98bf

Please sign in to comment.