From 433d8c868c34059fb92dde193dac5085c13deac9 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 16:56:48 +0300 Subject: [PATCH 01/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index af0b01dd6d..41c7bd2712 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit af0b01dd6d9bcb1e3bd8f5b95e33ac1273dd1be2 +Subproject commit 41c7bd271202ffec073a7a811860fdc88770e954 From 92b55a41cc235ab1821c0acefd7ef099cb95f9d2 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 18:45:58 +0300 Subject: [PATCH 02/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 41c7bd2712..bb9a492d60 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 41c7bd271202ffec073a7a811860fdc88770e954 +Subproject commit bb9a492d60803a75d5ee6584aa6f87abef21499f From acf87e8d16d37390242821be2a29fa73cd8ab05b Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Thu, 25 Apr 2019 18:48:01 +0300 Subject: [PATCH 03/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index bb9a492d60..cadb99be67 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit bb9a492d60803a75d5ee6584aa6f87abef21499f +Subproject commit cadb99be670e2a1bbe672bdf4cb62ad46232aa65 From e7a7e1451e9620ae85891218b93a8e1d3e4c2131 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 26 Apr 2019 14:30:22 +0300 Subject: [PATCH 04/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index cadb99be67..0d19f2112a 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit cadb99be670e2a1bbe672bdf4cb62ad46232aa65 +Subproject commit 0d19f2112a613bf67fc1ea8aefdf5c8418f1fd6c From 764581f45d34df1026cee0b9847e30b183279526 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 26 Apr 2019 16:54:54 +0300 Subject: [PATCH 05/33] Add unselected block accessibility --- gutenberg | 2 +- src/block-management/block-holder.js | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gutenberg b/gutenberg index 0d19f2112a..183e7fbbd1 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 0d19f2112a613bf67fc1ea8aefdf5c8418f1fd6c +Subproject commit 183e7fbbd1c93075855135ad6ad5fcf556c4106a diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index beefcb3d18..e76944ad6f 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -26,8 +26,9 @@ import { import { withDispatch, withSelect } from '@wordpress/data'; import { compose } from '@wordpress/compose'; import { addAction, removeAction, hasAction } from '@wordpress/hooks'; -import { getBlockType } from '@wordpress/blocks'; +import { getBlockType, getUnregisteredTypeHandlerName } from '@wordpress/blocks'; import { BlockEdit } from '@wordpress/block-editor'; +import { __, _x } from '@wordpress/i18n'; /** * Internal dependencies @@ -197,8 +198,23 @@ export class BlockHolder extends React.Component { ); } + accessibilityLabel() { + const { title, attributes, name } = this.props; + if ( name === getUnregisteredTypeHandlerName() ) { // is the block unrecognized? + return title; //already localized + } + else { + return sprintf( + /* translators: accessibility text. 1: block name. 2: block content information. */ + _x('%1$s block. %2$s', "Accessibility text for a block"), + title, //already localized + attributes.accessibilityContent || '' + ); + } + } + render() { - const { isSelected, borderStyle, focusedBorderColor } = this.props; + const { isSelected, borderStyle, focusedBorderColor, attributes } = this.props; const borderColor = isSelected ? focusedBorderColor : 'transparent'; @@ -206,8 +222,8 @@ export class BlockHolder extends React.Component { // accessible prop needs to be false to access children // https://facebook.github.io/react-native/docs/accessibility#accessible-ios-android @@ -243,6 +259,7 @@ export default compose( [ const isSelected = isBlockSelected( clientId ); const isFirstBlock = order === 0; const isLastBlock = order === getBlocks().length - 1; + const title = getBlockType( name ).title; return { attributes, @@ -254,6 +271,7 @@ export default compose( [ isLastBlock, isSelected, name, + title, }; } ), withDispatch( ( dispatch, { clientId, rootClientId } ) => { From f48708713a8e5d4aef95f093415080260f95217e Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 26 Apr 2019 17:53:21 +0300 Subject: [PATCH 06/33] Move block unselected state accessibility handling to block-holder --- gutenberg | 2 +- src/block-management/block-holder.js | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gutenberg b/gutenberg index 183e7fbbd1..4ca3727265 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 183e7fbbd1c93075855135ad6ad5fcf556c4106a +Subproject commit 4ca372726530c4557f5cacf6a8d0de0cfb9dc388 diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index e76944ad6f..699939fe35 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -28,7 +28,7 @@ import { compose } from '@wordpress/compose'; import { addAction, removeAction, hasAction } from '@wordpress/hooks'; import { getBlockType, getUnregisteredTypeHandlerName } from '@wordpress/blocks'; import { BlockEdit } from '@wordpress/block-editor'; -import { __, _x } from '@wordpress/i18n'; +import { sprintf, _x } from '@wordpress/i18n'; /** * Internal dependencies @@ -200,21 +200,21 @@ export class BlockHolder extends React.Component { accessibilityLabel() { const { title, attributes, name } = this.props; + const { getAccessibilityContent = () => '' } = attributes; if ( name === getUnregisteredTypeHandlerName() ) { // is the block unrecognized? return title; //already localized } - else { - return sprintf( - /* translators: accessibility text. 1: block name. 2: block content information. */ - _x('%1$s block. %2$s', "Accessibility text for a block"), - title, //already localized - attributes.accessibilityContent || '' - ); - } + + return sprintf( + /* translators: accessibility text. 1: block name. 2: block content information. */ + _x( '%1$s block. %2$s', 'Accessibility text for a block' ), + title, //already localized + getAccessibilityContent() || '' + ); } render() { - const { isSelected, borderStyle, focusedBorderColor, attributes } = this.props; + const { isSelected, borderStyle, focusedBorderColor } = this.props; const borderColor = isSelected ? focusedBorderColor : 'transparent'; @@ -224,6 +224,7 @@ export class BlockHolder extends React.Component { @@ -259,7 +260,7 @@ export default compose( [ const isSelected = isBlockSelected( clientId ); const isFirstBlock = order === 0; const isLastBlock = order === getBlocks().length - 1; - const title = getBlockType( name ).title; + const title = getBlockType( name ) !== undefined ? getBlockType( name ).title : ''; return { attributes, From f8b3f2ceb8626ff3e3474fba5b15fe9f7e91b52d Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Fri, 26 Apr 2019 17:58:42 +0300 Subject: [PATCH 07/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 4ca3727265..4081255dcb 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 4ca372726530c4557f5cacf6a8d0de0cfb9dc388 +Subproject commit 4081255dcb2a3ac50013ce1fde90f7ae2cf03c28 From 81450c611c9789cf64c6c87e29b048f8a6bdc8a7 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Fri, 26 Apr 2019 20:00:58 +0200 Subject: [PATCH 08/33] Add getAccessibilityLabel to block settings --- gutenberg | 2 +- src/block-management/block-holder.js | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gutenberg b/gutenberg index 4081255dcb..bee747ec25 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 4081255dcb2a3ac50013ce1fde90f7ae2cf03c28 +Subproject commit bee747ec2505a411c172b816778c12b9b669f600 diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 699939fe35..3c1a99dd62 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -198,19 +198,26 @@ export class BlockHolder extends React.Component { ); } - accessibilityLabel() { + getAccessibilityLabel() { const { title, attributes, name } = this.props; - const { getAccessibilityContent = () => '' } = attributes; + if ( name === getUnregisteredTypeHandlerName() ) { // is the block unrecognized? return title; //already localized } - return sprintf( - /* translators: accessibility text. 1: block name. 2: block content information. */ - _x( '%1$s block. %2$s', 'Accessibility text for a block' ), + const blockName = sprintf( + /* translators: accessibility text. %s: block name. */ + _x( '%1$s block' ), title, //already localized - getAccessibilityContent() || '' ); + + const blockType = getBlockType( name ); + if ( blockType.getAccessibilityLabel ) { + const blockAccessibilityLabel = blockType.getAccessibilityLabel( attributes ) || ''; + return blockName + ( blockAccessibilityLabel ? '. ' + blockAccessibilityLabel : '' ); + } + + return blockName; } render() { @@ -223,7 +230,7 @@ export class BlockHolder extends React.Component { // https://facebook.github.io/react-native/docs/accessibility#accessible-ios-android From 7f3dcb3c1064bf54dc4890588e6a01b270a4a670 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 15 May 2019 18:31:22 +0200 Subject: [PATCH 09/33] Update gb ref and use __experimentalGetAccessibilityLabel --- gutenberg | 2 +- src/block-management/block-holder.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gutenberg b/gutenberg index bee747ec25..aa8f662e24 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit bee747ec2505a411c172b816778c12b9b669f600 +Subproject commit aa8f662e2403e09ccc213941125c6e1e3d5f1c24 diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 3c1a99dd62..e50a8368ad 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -213,7 +213,7 @@ export class BlockHolder extends React.Component { const blockType = getBlockType( name ); if ( blockType.getAccessibilityLabel ) { - const blockAccessibilityLabel = blockType.getAccessibilityLabel( attributes ) || ''; + const blockAccessibilityLabel = blockType.__experimentalGetAccessibilityLabel( attributes ) || ''; return blockName + ( blockAccessibilityLabel ? '. ' + blockAccessibilityLabel : '' ); } From 8d7ebda17da4c77068ec7119ea86b78b7d20945e Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Thu, 16 May 2019 13:51:22 +0200 Subject: [PATCH 10/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index aa8f662e24..e587ded0a5 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit aa8f662e2403e09ccc213941125c6e1e3d5f1c24 +Subproject commit e587ded0a5fe8f177d1b4efb0bcdb2e2fa4b62af From e83fde468a9a81138a919b8256128b644d6b98f0 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Fri, 17 May 2019 10:23:16 +0200 Subject: [PATCH 11/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index e587ded0a5..2d7a20b011 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit e587ded0a5fe8f177d1b4efb0bcdb2e2fa4b62af +Subproject commit 2d7a20b011d174b1c887421afff8a6aec38e9585 From f9daad9f6cee1ccbcd7b72610001ed4bb2f3623b Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Fri, 17 May 2019 10:27:33 +0200 Subject: [PATCH 12/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 2d7a20b011..fb577f5119 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 2d7a20b011d174b1c887421afff8a6aec38e9585 +Subproject commit fb577f5119da59c4c6423fc897b0437b6725f2de From fbeba8c3b5d6ed445c3f6078627ef7f93fb55e2e Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Fri, 17 May 2019 10:43:25 +0200 Subject: [PATCH 13/33] Fix type def in BlockHolder --- src/block-management/block-holder.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 073964f243..732986a7ef 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -38,6 +38,9 @@ import styles from './block-holder.scss'; import InlineToolbar, { InlineToolbarActions } from './inline-toolbar'; type PropsType = BlockType & { + name: string, + title: string, + attributes: mixed, clientId: string, rootClientId: string, isSelected: boolean, @@ -48,9 +51,6 @@ type PropsType = BlockType & { testID: string, focusedBorderColor: string, getBlockIndex: ( clientId: string, rootClientId: string ) => number, - getPreviousBlockClientId: ( clientId: string ) => string, - getNextBlockClientId: ( clientId: string ) => string, - getBlockName: ( clientId: string ) => string, onChange: ( attributes: mixed ) => void, onInsertBlocks: ( blocks: Array, index: number ) => void, onCaretVerticalPositionChange: ( targetId: number, caretY: number, previousCaretY: ?number ) => void, @@ -95,7 +95,7 @@ export class BlockHolder extends React.Component { removeAction( 'blocks.onRemoveBlockCheckUpload', 'gutenberg-mobile/blocks' ); requestImageUploadCancel( mediaId ); } - } + }; onInlineToolbarButtonPressed = ( button: number ) => { Keyboard.dismiss(); @@ -224,8 +224,6 @@ export default compose( [ getBlockName, getBlockIndex, getBlocks, - getPreviousBlockClientId, - getNextBlockClientId, isBlockSelected, } = select( 'core/block-editor' ); const name = getBlockName( clientId ); @@ -237,16 +235,13 @@ export default compose( [ const title = getBlockType( name ) !== undefined ? getBlockType( name ).title : ''; return { + name, + title, attributes, getBlockIndex, - getBlockName, - getPreviousBlockClientId, - getNextBlockClientId, isFirstBlock, isLastBlock, isSelected, - name, - title, }; } ), withDispatch( ( dispatch, { clientId, rootClientId }, { select } ) => { From 4bbd25bc97e89cb09b1bc4aabdebe9f7b1aff601 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Thu, 23 May 2019 15:01:51 +0200 Subject: [PATCH 14/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index fb577f5119..0dffbb1c21 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit fb577f5119da59c4c6423fc897b0437b6725f2de +Subproject commit 0dffbb1c21b3e557100cfdc0e9c04084eff8ecf1 From 95166be4ab4534b18c31991faf0dc91b4f4a2927 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Thu, 23 May 2019 18:01:32 +0200 Subject: [PATCH 15/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 0dffbb1c21..963e0d0731 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 0dffbb1c21b3e557100cfdc0e9c04084eff8ecf1 +Subproject commit 963e0d07319343a2bf9271690c82fba84a8b748e From 3199fab953cef249fb5cbaa426e008fb1ae968e1 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Thu, 23 May 2019 18:38:56 +0200 Subject: [PATCH 16/33] Handle setting UnrecognizedBlock accessibility label in BlockHolder --- gutenberg | 2 +- src/block-management/block-holder.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gutenberg b/gutenberg index 963e0d0731..23aae0358c 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 963e0d07319343a2bf9271690c82fba84a8b748e +Subproject commit 23aae0358ce0c522a2dd728934211e30b731e1a2 diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 732986a7ef..b5246e2946 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -28,7 +28,8 @@ import { compose } from '@wordpress/compose'; import { addAction, removeAction, hasAction } from '@wordpress/hooks'; import { getBlockType, getUnregisteredTypeHandlerName } from '@wordpress/blocks'; import { BlockEdit } from '@wordpress/block-editor'; -import { sprintf, _x } from '@wordpress/i18n'; +import { sprintf, __ } from '@wordpress/i18n'; +import { coreBlocks } from '@wordpress/block-library'; /** * Internal dependencies @@ -169,12 +170,18 @@ export class BlockHolder extends React.Component { const { title, attributes, name } = this.props; if ( name === getUnregisteredTypeHandlerName() ) { // is the block unrecognized? - return title; //already localized + const blockType = coreBlocks[ attributes.originalName ]; + const title = blockType ? blockType.settings.title : attributes.originalName; + return sprintf( + /* translators: accessibility text. %s: unsupported block type. */ + __( 'Unsupported block: %s' ), + title + ); } const blockName = sprintf( /* translators: accessibility text. %s: block name. */ - _x( '%1$s block' ), + __( '%s block' ), title, //already localized ); From 1d752c9b92f162cbc319cae4d6b8388fbf8b4887 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Thu, 23 May 2019 18:40:33 +0200 Subject: [PATCH 17/33] Handle setting UnrecognizedBlock accessibility label in BlockHolder --- src/block-management/block-holder.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index b5246e2946..3341b9a4d0 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -171,11 +171,10 @@ export class BlockHolder extends React.Component { if ( name === getUnregisteredTypeHandlerName() ) { // is the block unrecognized? const blockType = coreBlocks[ attributes.originalName ]; - const title = blockType ? blockType.settings.title : attributes.originalName; return sprintf( /* translators: accessibility text. %s: unsupported block type. */ __( 'Unsupported block: %s' ), - title + blockType ? blockType.settings.title : attributes.originalName ); } From 1836bf65c584737f06c64bb0c2cdbb084780a78c Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Mon, 27 May 2019 12:53:32 +0200 Subject: [PATCH 18/33] Use order props instead of passing getBlockIndex --- src/block-management/block-holder.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 12c0a18071..1745cf007d 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -40,6 +40,7 @@ import InlineToolbar, { InlineToolbarActions } from './inline-toolbar'; type PropsType = BlockType & { name: string, + order: number, title: string, attributes: mixed, clientId: string, @@ -50,7 +51,6 @@ type PropsType = BlockType & { showTitle: boolean, borderStyle: Object, focusedBorderColor: string, - getBlockIndex: ( clientId: string, rootClientId: string ) => number, onChange: ( attributes: mixed ) => void, onInsertBlocks: ( blocks: Array, index: number ) => void, onCaretVerticalPositionChange: ( targetId: number, caretY: number, previousCaretY: ?number ) => void, @@ -116,8 +116,7 @@ export class BlockHolder extends React.Component { }; insertBlocksAfter = ( blocks: Array ) => { - const order = this.props.getBlockIndex( this.props.clientId, this.props.rootClientId ); - this.props.onInsertBlocks( blocks, order + 1 ); + this.props.onInsertBlocks( blocks, this.props.order + 1 ); if ( blocks[ 0 ] ) { // focus on the first block inserted @@ -158,8 +157,7 @@ export class BlockHolder extends React.Component { } getAccessibilityLabelForBlock() { - const { clientId, name, rootClientId } = this.props; - const order = this.props.getBlockIndex( clientId, rootClientId ); + const { name, order } = this.props; let blockTitle = getBlockType( name ).title; blockTitle = blockTitle === 'Unrecognized Block' ? blockTitle : `${ blockTitle } Block`; @@ -253,9 +251,9 @@ export default compose( [ return { name, + order, title, attributes, - getBlockIndex, isFirstBlock, isLastBlock, isSelected, From 4c7809c4e0d244a2fbcb63c8a5e3a4cb2dd5dbf0 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Tue, 28 May 2019 13:51:08 +0200 Subject: [PATCH 19/33] Fix lint errors --- __device-tests__/pages/editor-page.js | 6 ++--- src/block-management/block-holder.js | 35 ++++++++++++++++++--------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/__device-tests__/pages/editor-page.js b/__device-tests__/pages/editor-page.js index da9b0ca150..4d047ce5d4 100644 --- a/__device-tests__/pages/editor-page.js +++ b/__device-tests__/pages/editor-page.js @@ -40,8 +40,7 @@ export default class EditorPage { // position uses one based numbering async getBlockAtPosition( position: number, blockName: string ) { const blockLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`; - const elements = await this.driver.elementsByXPath( blockLocator ); - return elements[0]; + return await this.driver.elementByXPath( blockLocator ); } async hasBlockAtPosition( position: number, blockName: string = '' ) { @@ -76,8 +75,7 @@ export default class EditorPage { throw Error( `No Block at position ${ position }` ); } - let parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`; - + const parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`; let blockLocator = `${ parentLocator }/following-sibling::*`; blockLocator += isAndroid() ? '' : '//*'; blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block up from row ${ position } to row ${ position - 1 }"]`; diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 101326560f..37406a9cae 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -39,10 +39,11 @@ import styles from './block-holder.scss'; import InlineToolbar, { InlineToolbarActions } from './inline-toolbar'; type PropsType = BlockType & { - icon: ?mixed, + icon: mixed, name: string, order: number, title: string, + originalBlockTitle: string, attributes: mixed, clientId: string, rootClientId: string, @@ -61,6 +62,7 @@ type PropsType = BlockType & { moveBlockUp: () => void, moveBlockDown: () => void, removeBlock: () => void, + getAccessibilityLabelExtra: ( attributes: mixed ) => string }; type StateType = { @@ -166,30 +168,29 @@ export class BlockHolder extends React.Component { } getAccessibilityLabel() { - const { attributes, name, order, blockType, originalBlockType } = this.props; + const { attributes, name, order, title, originalBlockTitle, getAccessibilityLabelExtra } = this.props; let blockName = ''; if ( name === 'core/missing' ) { // is the block unrecognized? - const usupportedBlockName = originalBlockType && originalBlockType.settings.title || attributes.originalName; - blockName = blockType.title + '. ' + usupportedBlockName; + blockName = title + '. ' + originalBlockTitle; } else { blockName = sprintf( /* translators: accessibility text. %s: block name. */ __( '%s Block' ), - blockType.title, //already localized + title, //already localized ); } blockName += '. ' + sprintf( __( 'Row %d.' ), order + 1 ); // Disable adding any specific block accessibility information when running e2e tests - if ( blockType.__experimentalGetAccessibilityLabel ) { - const blockAccessibilityLabel = blockType.__experimentalGetAccessibilityLabel( attributes ) || ''; - blockName += blockAccessibilityLabel ? ' ' + blockAccessibilityLabel : '' ; + if ( getAccessibilityLabelExtra ) { + const blockAccessibilityLabel = getAccessibilityLabelExtra( attributes ); + blockName += blockAccessibilityLabel ? ' ' + blockAccessibilityLabel : ''; } - return blockName ; // Use one indexing for better accessibility + return blockName; // Use one indexing for better accessibility } render() { @@ -241,18 +242,28 @@ export default compose( [ const block = __unstableGetBlockWithoutInnerBlocks( clientId ); const { name, attributes, isValid } = block || {}; const blockType = getBlockType( name ); + const title = blockType.title; + const icon = blockType.icon; + const getAccessibilityLabelExtra = blockType.__experimentalGetAccessibilityLabel; const originalBlockType = attributes && attributes.originalName && coreBlocks[ attributes.originalName ]; + let originalBlockTitle = ''; + if ( originalBlockType ) { + originalBlockTitle = originalBlockType.settings.title || attributes.originalName; + } return { + icon, + name, + order, + title, attributes, blockType, isFirstBlock, isLastBlock, isSelected, isValid, - name, - order, - originalBlockType, + originalBlockTitle, + getAccessibilityLabelExtra, }; } ), withDispatch( ( dispatch, { clientId, rootClientId }, { select } ) => { From db6a23a2d59b71e492a9f44ec9ca504ddd6b4827 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Tue, 28 May 2019 14:17:09 +0200 Subject: [PATCH 20/33] Make sure the block attributes have updated before searching using the accessibility attribute --- __device-tests__/pages/editor-page.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/__device-tests__/pages/editor-page.js b/__device-tests__/pages/editor-page.js index 4d047ce5d4..b06796584c 100644 --- a/__device-tests__/pages/editor-page.js +++ b/__device-tests__/pages/editor-page.js @@ -40,7 +40,8 @@ export default class EditorPage { // position uses one based numbering async getBlockAtPosition( position: number, blockName: string ) { const blockLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`; - return await this.driver.elementByXPath( blockLocator ); + const elements = await this.driver.elementsByXPath( blockLocator ); + return elements[ 0 ]; } async hasBlockAtPosition( position: number, blockName: string = '' ) { @@ -155,6 +156,7 @@ export default class EditorPage { async sendTextToParagraphBlock( block: wd.PromiseChainWebdriver.Element, text: string ) { const textViewElement = await this.getTextViewForParagraphBlock( block ); await typeString( this.driver, textViewElement, text ); + await this.driver.sleep( 1000 ); // Give time for the block to rerender (such as for accessibility) } async sendTextToParagraphBlockAtPosition( position: number, text: string ) { From a78164913eab1cdace6d67c781271fc2d4215973 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Tue, 28 May 2019 14:27:38 +0200 Subject: [PATCH 21/33] Handle case where no blockType is found --- src/block-management/block-holder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 37406a9cae..93fb461aee 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -241,7 +241,7 @@ export default compose( [ const isLastBlock = order === getBlocks().length - 1; const block = __unstableGetBlockWithoutInnerBlocks( clientId ); const { name, attributes, isValid } = block || {}; - const blockType = getBlockType( name ); + const blockType = getBlockType( name || 'core/missing' ); const title = blockType.title; const icon = blockType.icon; const getAccessibilityLabelExtra = blockType.__experimentalGetAccessibilityLabel; From 4cb4ad7033dbd12a5b36e76f9624acf1a43f422a Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Tue, 28 May 2019 14:51:20 +0200 Subject: [PATCH 22/33] Revert unnecessary changes to e2e --- __device-tests__/pages/editor-page.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/__device-tests__/pages/editor-page.js b/__device-tests__/pages/editor-page.js index b06796584c..3ef5d6c248 100644 --- a/__device-tests__/pages/editor-page.js +++ b/__device-tests__/pages/editor-page.js @@ -131,7 +131,7 @@ export default class EditorPage { // ========================= async addNewParagraphBlock() { - return this.addNewBlock( this.paragraphBlockName ); + await this.addNewBlock( this.paragraphBlockName ); } async getParagraphBlockAtPosition( position: number ) { @@ -198,15 +198,15 @@ export default class EditorPage { // ========================= async addNewListBlock() { - return await this.addNewBlock( this.listBlockName ); + await this.addNewBlock( this.listBlockName ); } async getListBlockAtPosition( position: number ) { - return await this.getBlockAtPosition( position, this.listBlockName ); + return this.getBlockAtPosition( position, this.listBlockName ); } async hasListBlockAtPosition( position: number ) { - return await this.hasBlockAtPosition( position, this.listBlockName ); + return this.hasBlockAtPosition( position, this.listBlockName ); } async getTextViewForListBlock( block: wd.PromiseChainWebdriver.Element ) { From 4400544e37ede0e909b2e1d50a248b7906fa38ae Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Tue, 28 May 2019 15:10:03 +0200 Subject: [PATCH 23/33] Update e2e test descriptions --- __device-tests__/gutenberg-editor-lists-end.test.js | 2 +- __device-tests__/gutenberg-editor-lists.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__device-tests__/gutenberg-editor-lists-end.test.js b/__device-tests__/gutenberg-editor-lists-end.test.js index 85a30b7a82..21460001ee 100644 --- a/__device-tests__/gutenberg-editor-lists-end.test.js +++ b/__device-tests__/gutenberg-editor-lists-end.test.js @@ -14,7 +14,7 @@ import testData from './helpers/test-data'; jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000; -describe( 'Gutenberg Editor tests', () => { +describe( 'Gutenberg Editor tests for List block (end)', () => { let driver; let editorPage; let allPassed = true; diff --git a/__device-tests__/gutenberg-editor-lists.test.js b/__device-tests__/gutenberg-editor-lists.test.js index 3750dd1282..4ef6bcfae2 100644 --- a/__device-tests__/gutenberg-editor-lists.test.js +++ b/__device-tests__/gutenberg-editor-lists.test.js @@ -14,7 +14,7 @@ import testData from './helpers/test-data'; jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000; -describe( 'Gutenberg Editor tests', () => { +describe( 'Gutenberg Editor tests for List block', () => { let driver; let editorPage; let allPassed = true; From a55b735c837a180d5f49e73b21a4e46df078bd0b Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 28 May 2019 13:57:23 -0500 Subject: [PATCH 24/33] * Use deepest element when retrieving block * Include Node debug option for IntelliJ --- __device-tests__/pages/editor-page.js | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/__device-tests__/pages/editor-page.js b/__device-tests__/pages/editor-page.js index 3ef5d6c248..3caa5429b2 100644 --- a/__device-tests__/pages/editor-page.js +++ b/__device-tests__/pages/editor-page.js @@ -41,7 +41,7 @@ export default class EditorPage { async getBlockAtPosition( position: number, blockName: string ) { const blockLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`; const elements = await this.driver.elementsByXPath( blockLocator ); - return elements[ 0 ]; + return elements[ elements.length - 1 ]; } async hasBlockAtPosition( position: number, blockName: string = '' ) { @@ -121,7 +121,6 @@ export default class EditorPage { } removeBlockLocator += `[@${ this.accessibilityIdXPathAttrib }="${ removeButtonIdentifier }"]`; - const removeButton = await this.driver.elementByXPath( removeBlockLocator ); await removeButton.click(); } diff --git a/package.json b/package.json index b6795f4fc3..5f8028bf6d 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "test:inside-gb": "cross-env NODE_ENV=test jest --verbose --config jest_gb.config.js", "test:debug": "cross-env NODE_ENV=test node --inspect-brk jest --runInBand --verbose --config jest.config.js", "device-tests": "cross-env NODE_ENV=test jest --runInBand --reporters=default --reporters=jest-junit --detectOpenHandles --verbose --config jest_ui.config.js", - "device-tests:debug": "cross-env NODE_ENV=test node --inspect-brk node_modules/jest/bin/jest --runInBand --reporters=default --reporters=jest-junit --detectOpenHandles --verbose --config jest_ui.config.js", + "device-tests:debug": "cross-env NODE_ENV=test node $NODE_DEBUG_OPTION --inspect-brk node_modules/jest/bin/jest --runInBand --reporters=default --reporters=jest-junit --detectOpenHandles --verbose --config jest_ui.config.js", "test:e2e": "yarn test:e2e:android && yarn test:e2e:ios", "test:e2e:android": "TEST_RN_PLATFORM=android yarn device-tests", "test:e2e:android:debug": "TEST_RN_PLATFORM=android yarn device-tests:debug", From ac1efc59fa5abaca635b4c79c1ec5bf04eb94ed7 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 29 May 2019 12:44:55 +0200 Subject: [PATCH 25/33] Use element.sendKeys instead of element.type to avoid Keyboard not found errors --- __device-tests__/helpers/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__device-tests__/helpers/utils.js b/__device-tests__/helpers/utils.js index 0695711a73..d1e525eb2b 100644 --- a/__device-tests__/helpers/utils.js +++ b/__device-tests__/helpers/utils.js @@ -162,7 +162,7 @@ const typeString = async ( driver: wd.PromiseChainWebdriver, element: wd.Promise } } } else { - return await element.type( str ); + return await element.sendKeys( str ); } }; From ec967eab6459575daf8b1741aa57e479646c0bb1 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 29 May 2019 12:45:35 +0200 Subject: [PATCH 26/33] Move accessible prop to TouchableWithoutFeedback --- src/block-management/block-holder.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 93fb461aee..9cae2ea922 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -184,13 +184,12 @@ export class BlockHolder extends React.Component { blockName += '. ' + sprintf( __( 'Row %d.' ), order + 1 ); - // Disable adding any specific block accessibility information when running e2e tests if ( getAccessibilityLabelExtra ) { const blockAccessibilityLabel = getAccessibilityLabelExtra( attributes ); blockName += blockAccessibilityLabel ? ' ' + blockAccessibilityLabel : ''; } - return blockName; // Use one indexing for better accessibility + return blockName; } render() { @@ -205,11 +204,11 @@ export class BlockHolder extends React.Component { // https://facebook.github.io/react-native/docs/accessibility#accessible-ios-android { this.props.showTitle && this.renderBlockTitle() } Date: Wed, 29 May 2019 13:01:12 +0200 Subject: [PATCH 27/33] Revert to using type --- __device-tests__/helpers/utils.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/__device-tests__/helpers/utils.js b/__device-tests__/helpers/utils.js index d1e525eb2b..e1244a7c6a 100644 --- a/__device-tests__/helpers/utils.js +++ b/__device-tests__/helpers/utils.js @@ -138,9 +138,6 @@ const stopDriver = async ( driver: wd.PromiseChainWebdriver ) => { } }; -// attempts to type a string to a given element, need for this stems from -// https://github.com/appium/appium/issues/12285#issuecomment-471872239 -// https://github.com/facebook/WebDriverAgent/issues/1084 const typeString = async ( driver: wd.PromiseChainWebdriver, element: wd.PromiseChainWebdriver.Element, str: string, clear: boolean = false ) => { if ( clear ) { await element.clear(); @@ -162,7 +159,7 @@ const typeString = async ( driver: wd.PromiseChainWebdriver, element: wd.Promise } } } else { - return await element.sendKeys( str ); + return await element.type( str ); } }; From 8ba89049acb856d238976c139c819e0552564386 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 29 May 2019 13:07:55 +0200 Subject: [PATCH 28/33] Fix lint error --- src/block-management/block-holder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 9cae2ea922..35f133af49 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -252,7 +252,7 @@ export default compose( [ return { icon, - name: name || 'core/missing' , + name: name || 'core/missing', order, title, attributes, From ef0a086ad1b8c429de1f186da3a205fe8f693be3 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Mon, 3 Jun 2019 14:09:32 +0200 Subject: [PATCH 29/33] Move all accessibility props to TouchableWithoutFeedback --- src/block-management/block-holder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index 35f133af49..a8bb1fd5d1 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -205,12 +205,12 @@ export class BlockHolder extends React.Component { { this.props.showTitle && this.renderBlockTitle() } { isValid && this.getBlockForType() } From a036757a2fbe46bbd6f137c942a35c78bf358988 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Mon, 3 Jun 2019 14:19:53 +0200 Subject: [PATCH 30/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index eaab9d2dab..5848a6735a 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit eaab9d2dabd78737729d5f94e552cfa06ed2b6a9 +Subproject commit 5848a6735a468c2465b58ef0584571e210993d1a From ab3f0a35ffb87d75f9e04c97a2e936f77247f9f4 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 5 Jun 2019 14:31:37 +0200 Subject: [PATCH 31/33] Have accessibilityLabel prop in the View to fix e2e tests --- src/block-management/block-holder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/block-management/block-holder.js b/src/block-management/block-holder.js index a8bb1fd5d1..e53a7ea967 100644 --- a/src/block-management/block-holder.js +++ b/src/block-management/block-holder.js @@ -206,11 +206,11 @@ export class BlockHolder extends React.Component { onPress={ this.onFocus } accessible={ ! isSelected } accessibilityRole={ 'button' } - accessibilityLabel={ accessibilityLabel } > { this.props.showTitle && this.renderBlockTitle() } { isValid && this.getBlockForType() } From ab049ed4e34303238817fe7399c043e191238809 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 5 Jun 2019 14:35:22 +0200 Subject: [PATCH 32/33] Update gutenberg ref --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 5848a6735a..9e7ef1b4a8 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 5848a6735a468c2465b58ef0584571e210993d1a +Subproject commit 9e7ef1b4a8b36e4898eb2ef5b5b439cebcacebb1 From 47aeee4632debe3422fb88089b59f1bd01bcdd2a Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Thu, 6 Jun 2019 14:14:50 +0200 Subject: [PATCH 33/33] Update gutenberg ref after merge --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 9e7ef1b4a8..ff70de6008 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 9e7ef1b4a8b36e4898eb2ef5b5b439cebcacebb1 +Subproject commit ff70de60086e8f505de51a9f9883d77bf5eda119