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

RichText: rewrite withFilters with hooks #19117

Merged
merged 16 commits into from Dec 17, 2019
Merged

RichText: rewrite withFilters with hooks #19117

merged 16 commits into from Dec 17, 2019

Conversation

@ellatrix
Copy link
Member

ellatrix commented Dec 13, 2019

Description

Removes rich-text's dependency on the hooks package.

Currently some props are added for the annotation format types with WordPress hooks. This is unnecessary, because RichText has access to the format types. Additionally the addition of the props can be simplified with hooks and a single wrapper component.

How has this been tested?

Screenshots

Types of changes

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. .
export { useDispatch } from './components/use-dispatch';
export {
useDispatch,
useDispatchWithMap as __unstableUseDispatchWithMap,

This comment has been minimized.

Copy link
@ellatrix

ellatrix Dec 13, 2019

Author Member

@youknowriad Just wanted to make you aware that I'm exporting useDispatchWithMap here (unstable API). It's needed for RichText because the format type needs access to dispatch to pick a store. I don't think there's any way around it, but maybe you have a better insight.

This comment has been minimized.

Copy link
@youknowriad

youknowriad Dec 17, 2019

Contributor

the format type needs access to dispatch to pick a store

Maybe, there's an alternative way to provide access to the hook in these types. Could you give a quick example about how we use dispatch in the formats?

This comment has been minimized.

Copy link
@ellatrix

ellatrix Dec 17, 2019

Author Member

Sure:

__experimentalGetPropsForEditableTreeChangeHandler( dispatch ) {
return {
removeAnnotation: dispatch( STORE_KEY ).__experimentalRemoveAnnotation,
updateAnnotationRange: dispatch( STORE_KEY ).__experimentalUpdateAnnotationRange,
};
},

@ellatrix ellatrix force-pushed the try/rich-text-filters branch from ff46818 to 13a20f7 Dec 17, 2019
@ellatrix

This comment has been minimized.

Copy link
Member Author

ellatrix commented Dec 17, 2019

Did a performance check and the results vary with slightly better performance for this branch.

@ellatrix ellatrix force-pushed the try/rich-text-filters branch from 8b37ea5 to 4c84630 Dec 17, 2019
@ellatrix ellatrix merged commit 33cbd3b into master Dec 17, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@ellatrix ellatrix deleted the try/rich-text-filters branch Dec 17, 2019
@hypest

This comment has been minimized.

Copy link
Contributor

hypest commented Dec 17, 2019

Headsup, formatTypes changes from this PR introduced a crash regression in the native mobile codepath. @mchowning is having more contect in this one (and is in the process of opening a gutenberg-mobile ticket to track. Edit: gutenberg-mobile ticket).

@youknowriad youknowriad added this to the Gutenberg 7.2 milestone Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.