-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Leaner code for the native mobile Toolbar #9064
Leaner code for the native mobile Toolbar #9064
Conversation
Some tests are failing. Example:
@gziolo or @youknowriad perhaps you have some hint about this one ^ ? Apparently it has something to do with the way the web version of the |
height={ size } | ||
viewBox="0 0 20 20" | ||
> | ||
<Path d={ path } /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this will work on the web. If you see my original code on my PR for the web the Path element is defined using lowercase. i.e: path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you did know you redefined Path also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I extracted the Path
component to its own component and Path
is imported here https://github.com/WordPress/gutenberg/pull/9064/files#diff-297ebddffcddddf088a365bab7f0909cR13. That should do it, although I think there's probably a problem with the way I've defined the web side variants (related to the comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this component is meant to be modified in the Dashicons repository first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the comments I saw on the file I thought this was the case, if we could a pointer to where to make the changes it will be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dashicons are edited in https://github.com/WordPress/dashicons. Feel free to ping me for help, I can fasttrack any changes you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be the file to modify on the Dashicons repo: https://github.com/WordPress/dashicons/blob/master/sources/react/index-footer.jsx. Not sure yet how to integrate that repo/project and have it hot-reloading in the React Native app but yeah, let's see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd like to make a PR, I can approve it for you and ship it to Gutenberg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youknowriad , it would still be good to review the proposal in this PR and agree on whether we like/want it or not before migrating the change to the Dashicons repo, so we take advantage of the quick turnaround time we enjoy with the Gutenberg+ReactNative repo combo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the best approach here would be to have an alternative index.native.js
for the whole dashicon component instead of extracting Path
and Svg
key={ [ indexOfSet, indexOfControl ].join() } | ||
keyProp={ [ indexOfSet, indexOfControl ].join() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we repeat key and keyProp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch, I should have mentioned this "gotcha" in the PR description. So, React has this set of "special" props that it doesn't propagate down to the child components. They call them Special Props. In this case, the key
property cannot be picked up by the ToolbarButtonContainer
component and we need to replicate it on purpose into a differently named prop, keyProp
.
I'll update the PR description to include it for future ref.
@@ -0,0 +1,8 @@ | |||
export default ( props ) => ( | |||
<div | |||
key={ props.keykeyProp } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be prop.keyProp
only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of the docs is that key
is used for the rendering reconciliation logic and since it was there in the original code (div
) it needs to be here in the web variant of the component too. I can be wrong though as my React knowledge is limited still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but keykeyPro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see now, that's a typo, good catch! Fixed with aed7db6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work on this.
I feel this change has some impacts on the web, and since we've freezed developpement fo |
Oh! I missed that this was merged against another branch, it's fine. Sorry for the confusion (The dashicons feedback is still valid though cc @jasmussen ) |
I know this PR is not merged to the parent #9012 but I'd like to add here that we should prolly name the functions/components in the modules so it's more clear which compos they are in the React inspector (notice the couple of "Unknown"s in the screenshot below): |
And oh, btw, I manually tested the Gutenberg changes and the toolbar works fine, as in, nothing seems broken on the UI. |
* Activate toolbar for RN. * Move toolbar to the top. * Implement RN icon buttons using SVG. * Add extra properties for toolbar selection. * Update url package entry point for RN. * Leaner code for the native mobile Toolbar (#9064) * Dedicated components for SVG, Path * Fix lint errors * Dedicated native components for button, icon-button, tooltip * Dedicated native mobile comps for Toolbar containers * Small code styling fix * Fix double "key" typo in prop name * Name the web side componets for better React debugging * Update the tests to cater for SVG, Path * Deconstruct arguments in single line. * Remove comment. * Remove unnecessary use of keyProp * Fix use of platform for iOS detection. * Update toolbar RN code to share more code with Web. * Update index.native.js * Address review comments. * Address eslint errors. * Remove extra white space. * Components: Add new primitives to work cross-platform * Keycodes: Include support for both iPad and iPhone when using external keyboard * Components: Use explicit name for Tooltip component in RN * Add token-list as a dependency to package.json to avoid random updates to the lock file * Return null to avoid failure on render. * Fix warning on SVG * Fix potential error on style. * Fix lint errors. * Fix lint error.
Description
This PR should be considered as additional work on top of #9012.
Changes:
Note:
Turns out there's we want to propagate a
key
prop down to theToolbarButtonContainer
component butkey
being a Special Prop for React it cannot be propagated. We need to mirror/replicate its value to another , differently named prop to pick it up inside the child component. See here.How has this been tested?
Using this PR on the gutenberg mobile repo.
Types of changes
Checklist: