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

[RNMobile] - Replace Slider with Stepper for columns settings on Gallery block #19947

Merged
merged 10 commits into from
Feb 12, 2020

Conversation

geriux
Copy link
Member

@geriux geriux commented Jan 29, 2020

Gutenberg Mobile PR -> wordpress-mobile/gutenberg-mobile#1834

Description

This PR replaces the RangeControl that handles the number of columns for the Gallery block with the Stepper component only for mobile.

It also changes the prop names of the Stepper component to match the RangeControl for simpler use. Since this component is not being used until now it was the best time to do it.

iOS Android

How has this been tested?

  • Open the app with metro running
  • Create a post
  • Add a Gallery block
  • Select some images
  • Open the block settings
  • Expect: See the new Stepper component under the Columns setting
  • Change the value and check it changes correctly

Screenshots

iOS Android

Types of changes

  • Replace the mobile component for another one.
  • Update the Stepper component props name to match the RangeControl

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.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@geriux geriux added [Status] In Progress Tracking issues with work in progress Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) labels Jan 29, 2020
@geriux geriux removed the [Status] In Progress Tracking issues with work in progress label Jan 29, 2020
@geriux geriux marked this pull request as ready for review January 29, 2020 14:03
@pinarol pinarol removed their request for review January 29, 2020 17:17
@geriux
Copy link
Member Author

geriux commented Jan 30, 2020

Hey, @mkevins 👋 Thanks for the feedback and for suggesting having the same props in the Stepper component so we can reduce the code for the Gallery. Since that component is not used yet it was the best time to update it. Feel free to review it again when you can.

@mkevins
Copy link
Contributor

mkevins commented Feb 3, 2020

Hi @geriux 👋 This is looking good! Thanks for those changes 👍 I tested on both Android (via Pixel 3a, Android 10) and iOS (via simulator - iPhone 11). Works mostly as expected. One observation is that on Android, the "repeat rate" was pretty fast:

I wonder if the STEP_SPEED could be adjusted, or if a separate initial delay can be added to avoid debounce the first tap (it was hard to get it not to jump 2 at a time, for example).

Also, not related to this PR, I noticed something in the code for stepper component:

On this line:

this.startPressInterval( callback, STEP_SPEED / 2 );
it seems that startPressInterval is invoked with a second argument (I assume a delay to "accelerate" repeats after 10 ticks). However, the function only seems to accept one argument (the callback):

The galleries I tested with did not have 10 or more images, so I didn't test the behavior, but I wanted to note that in case it's something worth taking another look at (also, if we need to change anything there, perhaps STEP_DELAY is a more accurate name than STEP_SPEED, e.g. when we divide it by 2, the speed actually should increase). Wdyt?

@geriux
Copy link
Member Author

geriux commented Feb 3, 2020

Thanks for reviewing it again!

it seems that startPressInterval is invoked with a second argument (I assume a delay to "accelerate" repeats after 10 ticks). However, the function only seems to accept one argument (the callback):

😱good thing you spotted this! Due to this missing argument, it was causing the other issues you mentioned about being too fast or an initial delay.

...also, if we need to change anything there, perhaps STEP_DELAY is a more accurate name than STEP_SPEED, e.g. when we divide it by 2, the speed actually should increase). Wdyt?

Sounds good to me! I'll change it since I'm fixing the argument issue.

Gerardo Pacheco added 4 commits February 3, 2020 12:09
…/stepper-gallery-settings

# Conflicts:
#	packages/block-library/src/gallery/edit.js
#	packages/components/src/mobile/bottom-sheet/stepper-cell/index.native.js
#	packages/components/src/mobile/stepper-control/index.native.js
@geriux
Copy link
Member Author

geriux commented Feb 3, 2020

@mkevins Updated with the feedback =)

Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

I tested again via WordPress apps on Android (Pixel 3a) and iOS (simulator). Everything works as expected. Nice work @geriux 👍

LGTM!

…thub.com:WordPress/gutenberg into rnmobile/stepper-gallery-settings

# Conflicts:
#	packages/components/src/mobile/stepper-control/README.md
@geriux geriux merged commit c77a602 into master Feb 12, 2020
@geriux geriux deleted the rnmobile/stepper-gallery-settings branch February 12, 2020 09:33
@github-actions github-actions bot added this to the Gutenberg 7.6 milestone Feb 12, 2020
@aduth
Copy link
Member

aduth commented Feb 13, 2020

I am seeing warnings that I suspect are related to this pull request, at least when running npm run storybook:dev.

[1] WARNING in ./packages/block-library/build-module/gallery/edit.js 70:60-74
[1] "export 'StepperControl' was not found in '@wordpress/components'
[1]  @ ./packages/block-library/build-module/gallery/index.js
[1]  @ ./packages/block-library/build-module/index.js
[1]  @ ./storybook/stories/playground/index.js
[1]  @ ./storybook/stories sync ^\.\/(?:(?:|\/|(?:(?:(?!(?:|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.(js|mdx))$
[1]  @ ./storybook/generated-entry.js
[1]  @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./node_modules/@storybook/addon-docs/dist/frameworks/common/config.js ./node_modules/@storybook/addon-docs/dist/frameworks/react/config.js ./storybook/preview.js ./node_modules/@storybook/addon-knobs/dist/preset/addDecorator.js ./storybook/generated-entry.js (webpack)-hot-middleware/client.js?reload=true&quiet=true

My guess is that this import is problematic in that there is no StepperControl implemented for web, so it cannot be imported:

import {
PanelBody,
RangeControl,
SelectControl,
StepperControl,
ToggleControl,
withNotices,
} from '@wordpress/components';

Separately, I would have some concern that we've introduced a diverging feature between mobile and web implementations (i.e. StepperControl in native but not web).

@mkevins
Copy link
Contributor

mkevins commented Feb 14, 2020

Hi @aduth 👋

I am seeing warnings that I suspect are related to this pull request

Indeed, this PR would be the source of that warning. It shouldn't be problematic for users (since we use the Platform module to "fork" the code path which uses StepperControl, but it'd be good to reduce the noise on the dev side if possible. I'm guessing the warning is thrown by one of the Webpack loaders? Not sure offhand what may be the best way to suppress that, perhaps via a stub 🤔 ?

Separately, I would have some concern that we've introduced a diverging feature between mobile and web implementations (i.e. StepperControl in native but not web).

I believe this was introduced to improve the UX on mobile for settings with small value ranges (i.e. < ~10), though I would defer that to @iamthomasbishop or @pinarol

@geriux
Copy link
Member Author

geriux commented Feb 14, 2020

Hey @aduth !

Separately, I would have some concern that we've introduced a diverging feature between mobile and web implementations (i.e. StepperControl in native but not web).

As @mkevins mentioned, it was introduced as a UX improvement on mobile, you can read more about this decision here

Regarding the warning, I'll put up a draft PR with a fix proposal.

Thank you for the heads up on this!

@geriux
Copy link
Member Author

geriux commented Feb 14, 2020

Here's the draft PR with the fix proposal #20231 any feedback / different approach is more than welcome =)

Thanks!

@gziolo
Copy link
Member

gziolo commented Apr 6, 2020

We published an update of WordPress packages to npm and this PR breaks Gallery block when used outside of Gutenberg. StepperControl is mobile-only, so it can't be used in edit.js.

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