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

Fix popover link repositioning #10032

Merged
merged 1 commit into from Sep 19, 2018

Conversation

Projects
None yet
2 participants
@talldan
Contributor

talldan commented Sep 19, 2018

Description

Fixes #7992, specifically "Link Modal doesn't move when clicking on another link within Paragraph block" - the steps mentioned here #7992 (comment)

Other issues couldn't be reproduced.

Problem
The PositionedAtSelection component used in LinkContainer only calculates its position when mounting. When clicking between two existing links in the same paragraph, the component doesn't remount, so therefore the position also doesn't change.

Fix
The Popover being rendered in LinkContainer already had a key specified that forces it to re-mount whenever a selection is changed. This has now been moved to the parent PositionedAtSelection to force that and its children to remount, resulting in a recalculation of the position.

I did consider/try some other approaches, but none worked quite as well as this.

How has this been tested?

  1. Add two separate links to a paragraph block
  2. Click on one, then click on the other.
  3. Observed that the link popover correctly repositioned and updated

Screenshots

Before
popover-reposition-bug

After
popover-reposition-fix

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
Move force remount up to PositionAtSelection. Ensures link popover po…
…sition changes when clicking between links

@talldan talldan added the [Type] Bug label Sep 19, 2018

@talldan talldan added this to the 4.0 milestone Sep 19, 2018

@talldan talldan self-assigned this Sep 19, 2018

@talldan talldan requested a review from WordPress/gutenberg-core Sep 19, 2018

@tofumatt

Nice. 👍

@talldan talldan merged commit f2139ae into master Sep 19, 2018

2 checks passed

codecov/project 48.69% remains the same compared to 99ca7ea
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@talldan talldan deleted the fix/link-popover-reposition branch Sep 19, 2018

@talldan

This comment has been minimized.

Show comment
Hide comment
@talldan

talldan Sep 19, 2018

Contributor

Cheers for the review!

Contributor

talldan commented Sep 19, 2018

Cheers for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment