-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Mobile] Use link picker in Image block #27292
Conversation
Size Change: 0 B Total Size: 1.28 MB ℹ️ View Unchanged
|
const mappedAttributes = { ...unMappedAttributes, url }; | ||
const setMappedAttributes = ( { url: href, ...restAttributes } ) => | ||
href === undefined | ||
? setAttributes( restAttributes ) | ||
: setAttributes( { ...restAttributes, href } ); |
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.
The link settings sets the attribute named url
, but Image block's url
attribute is the URL of the image itself, and instead uses the attribute named href
to represent the link URL.
Originally, to work around this, I used dynamic properties in LinkSettings
to allow the consumer to customize the attribute name to be set.
Here, I reverted those changes to LinkSettings
, and instead map the attibutes in ImageEdit
. As the link picker is used in more places, it might make sense to re-evaluate this pattern, depending on the commonality of the possible attribute names (e.g. url
, href
). WDYT?
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 like the dynamic properties approach. It seems fairly clean. The code ^ is a bit harder for me to understand. But I think this could be done as part of a larger refactor.
One thing that I noticed is that we always seem to set the options such as labels etc.
I think we could really benefit from having a default name for labels. so that we only pass in the options that are different from the default.
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 we could really benefit from having a default name for labels. so that we only pass in the options that are different from the default.
Exactly my thoughts! I think we can refactor during the iteration for further consolidation described here. I think with the refactor we should have the opportunity to both reduce the surface area of the interface, and also make the components appropriately general (in particular, decoupled from particular attribute names and even setAttributes
).
This PR worked really well for me. I tested it on the iOS simulator. I think the LinkSettings could use some better default options so that it would be harder to set the link setting labels to be different across the different instances. |
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.
Lets ship this and refactor how the options that we pass into the LinkSettingsNavigation
to have better defaults.
Sorry for the ping.. I pushed a revert to troubleshoot the failing test: https://github.com/WordPress/gutenberg/blame/master/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js#L86. |
This reverts commit f40b256.
This is an attempt to fix a failing test - I manually counted 26 assertions, instead of 27, so it looks correct. However, it still is not clear how this was passing before with 27.
Thank you Enej for reviewing and testing! 😃 |
Related PRs
gutenberg-mobile
: wordpress-mobile/gutenberg-mobile#2841WordPress-Android
: wordpress-mobile/WordPress-Android#13576Description
This PR adds the link picker functionality to the Image block settings, and auto-hides the "Open in new tab" and "rel" settings when a link is not present. This is a first step towards resolving: wordpress-mobile/gutenberg-mobile#1655.
This also auto-hides the "Open in new tab" setting for RichText based link editing.
Testing steps
Link picker
Open in new tab
RichText auto-hiding
Screenshots
Image block link settings
Note: the above screen recordings were created prior to autohiding the "Open in new tab" and "rel" settings.
Autohide settings
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: