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

Add native version of BlockMobileToolbar (Ported from gutenberg-mobile) #16177

Merged
merged 5 commits into from
Jun 18, 2019

Conversation

Tug
Copy link
Contributor

@Tug Tug commented Jun 14, 2019

Description

This is step 4 of wordpress-mobile/gutenberg-mobile#958
This PR ports the gutenberg-mobile InlineToolbar to gutenberg as the BlockMobileToolbar component inside @wordpress/block-editor.
This is needed to implement Inner blocks for mobile native. You can follow the progress of the port here wordpress-mobile/gutenberg-mobile#958

How has this been tested?

wordpress-mobile/gutenberg-mobile#1133

Types of changes

Adds native support for a block editor component

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@Tug Tug added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Jun 14, 2019
@Tug Tug added this to the Future milestone Jun 14, 2019
@Tug Tug requested review from koke, hypest and etoledom June 14, 2019 10:13
@Tug Tug self-assigned this Jun 14, 2019
@Tug Tug added the [Status] In Progress Tracking issues with work in progress label Jun 14, 2019
@Tug Tug force-pushed the rnmobile/add/block-mobile-toolbar-component branch from d4254c4 to 8f94c78 Compare June 17, 2019 08:06
Copy link
Contributor

@koke koke left a comment

Choose a reason for hiding this comment

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

I left a few suggestions, but the only one that feels like a blocker is the accessibility one. This is looking pretty good 👏

} ) => (
<>
<ToolbarButton
accessibilityLabel={ __( 'Move up' ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the accessibilityLabel needed if it's the same as label? If it is, then it's missing from the Move down button

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 about the accessibility labels concern.
Current develop has labels with more information, that (I think) are also used on UI Testing.
https://github.com/wordpress-mobile/gutenberg-mobile/blob/40c1374072a37b5bdf4c8730af3b68f5a5fb0f09/src/block-management/inline-toolbar/index.js#L58-L74

And the prop to set the accessibility label is actually title.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing, updating this 👍

const normalizedClientIds = castArray( clientIds );
const firstClientId = first( normalizedClientIds );
const rootClientId = getBlockRootClientId( first( normalizedClientIds ) );
const blockOrder = getBlockOrder( rootClientId );
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be only used for its length, maybe getBlockCount is a better selector?
On the other hand, if we're not actually looking at the results of getBlockOrder, couldn't we use the length of normalizedClientIds instead to find the last one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I just realized this is just what the web does. Do you think it'd make sense to share the select/dispatch logic and just fork the internal BlockMover component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not much in favor. Surely the components have similar names but they're not used the same way at the moment in web and native, I'd rather we keep them separated.
But in general, I'm all for reusing the web code whenever possible.

<View style={ styles.toolbar }>
<BlockMover clientIds={ [ clientId ] } />

<View style={ styles.spacer } />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that flexbox allows for this without the extra spacer view, although I haven't managed to do it directly on the inspector slot without a wrapper view:

<View style={ styles.inspectorControls }>
	<InspectorControls.Slot />
</View>
.inspectorControls {
	flex-grow: 1;
	align-items: flex-end;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes sense with flexbox. It's not like we're floating our elements left and right, we're pushing it to the sides thanks to a spacer.
A good alternative would be to make 2 groups of icons, each using flex as well and justifying content to the left and right. I did experiment a bit with it but I saw some strange behavior with the toolbar disappearing sometimes. The current solution seems to be working fine for us...

@Tug Tug force-pushed the rnmobile/add/block-mobile-toolbar-component branch from 8f94c78 to 4de9db1 Compare June 17, 2019 16:19
@Tug Tug removed the [Status] In Progress Tracking issues with work in progress label Jun 17, 2019
@Tug Tug force-pushed the rnmobile/add/block-mobile-toolbar-component branch from 89654e4 to 8611c43 Compare June 18, 2019 13:14
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Thank you @Tug for the updates!

I found a small issue with the indexes of "Move row down from...". I added a code comment with more details.

Fixing that I think this will be good to go 🎉

/* translators: accessibility text. %1: current block position (number). %2: next block position (number) */
__( 'Move block down from row %1$s to row %2$s' ),
lastIndex + 1,
lastIndex
Copy link
Contributor

Choose a reason for hiding this comment

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

On the first block, the move down button is read by VoiceOver as: "Move block down from row 1 to row 0".
It should say "... from row 1 to row 2".

The move up button is correct 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, for noticing, should be fixed now :)

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Working great now! 🎉

Copy link
Contributor

@koke koke left a comment

Choose a reason for hiding this comment

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

Since the accessibility issues are solved, looks good to me as well 👍

@Tug Tug merged commit f7bbf58 into master Jun 18, 2019
@Tug Tug deleted the rnmobile/add/block-mobile-toolbar-component branch June 18, 2019 13:53
@youknowriad youknowriad modified the milestones: Future, Gutenberg 6.0 Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants