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: Make ⌘A's select all the blocks again #7731

Merged
merged 2 commits into from Jul 6, 2018

Conversation

@jorgefilipecosta
Member

jorgefilipecosta commented Jul 5, 2018

Description

Fixes: #7711
Regressed in: #7644

Moves the logic to handle meta+a to be before the check for event.nativeEvent.defaultPrevented. The event was default prevented by TinyMCE.

How has this been tested?

Some smoke testing.
Added multiple paragraphs with text and checked that pressing ⌘A's multiple selected all the blocks.

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Jul 5, 2018

@@ -190,7 +190,7 @@ class WritingFlow extends Component {
// Aobrt if navigation has already been handled (e.g. TinyMCE inline

This comment has been minimized.

@mtias

mtias Jul 5, 2018

Contributor

There's a typo here "Aobrt"

@aduth

This comment has been minimized.

Member

aduth commented Jul 5, 2018

End-to-end test failure is legitimate. This is basically undoing what was meant to be fixed by #7644 / #6712

@aduth

Re-regresses #7644 . _navigationHandled isn't a thing. It's basically the same as if the condition isn't there at all.

@afercia

This comment has been minimized.

Contributor

afercia commented Jul 5, 2018

Also related: #7445

@jorgefilipecosta

This comment has been minimized.

Member

jorgefilipecosta commented Jul 5, 2018

This PR was updated it now reorders the check for ⌘A event to be before the check for event.nativeEvent.defaultPrevented. It seems TinyMCE applies a prevent default in the event.

@aduth

This comment has been minimized.

Member

aduth commented Jul 5, 2018

Future tasks:

  • Split WritingFlow#onKeyDown into more sensible isolated function handlers (we shouldn't have both block traversal and Cmd+A behaviors in the same function, it contributed to the introduction of the regression)
  • Try to interoperate better with TinyMCE's preventDefault, e.g. perhaps exploring the SelectAll command which is the source of the preventDefault, either stripping the default TinyMCE behavior, refactoring our 2x Cmd+A to act in response to the SelectAll command (similar to Undo/Redo propagation), or abandoning effort to use native preventDefault in favor of an implementation-specific property like which had existed prior to #7644

On glance, this looks good. Will take a closer look soon. Travis appears to be having a bad day.

@jorgefilipecosta jorgefilipecosta added this to the 3.2 milestone Jul 5, 2018

@jorgefilipecosta jorgefilipecosta self-assigned this Jul 5, 2018

} else if ( ! this.verticalRect ) {
this.verticalRect = computeCaretRect( target );
}
if ( ! isNav ) {

This comment has been minimized.

@iseulde

iseulde Jul 6, 2018

Member

Worth leaving a comment on the order?

This comment has been minimized.

@jorgefilipecosta

jorgefilipecosta Jul 6, 2018

Member

Well remembered, the comment was added.

jorgefilipecosta and others added some commits Jul 5, 2018

@iseulde

iseulde approved these changes Jul 6, 2018

Looks fine to me. Added an e2e test to ensure we don't break it in the future. Arrow nav still works as expected.

The PR was updated to use another approach.

@jorgefilipecosta jorgefilipecosta merged commit c33bb2a into master Jul 6, 2018

2 checks passed

codecov/project 48.4% remains the same compared to 87252f2
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/Consecutive-A-do-not-work-anymore branch Jul 6, 2018

@jorgefilipecosta

This comment has been minimized.

Member

jorgefilipecosta commented Jul 6, 2018

Thank you for the review and for suggesting this approach @aduth. Thank you @iseulde for the review and for the end to end test 👍

@aduth

This comment has been minimized.

Member

aduth commented Jul 6, 2018

Thanks for the added end-to-end test!

@mcsf

This comment has been minimized.

Contributor

mcsf commented Oct 15, 2018

Just noting that, at least as of today:

  • Firefox requires three ⌘A presses.
  • Safari doesn't seem to care about this feature at all.
@mcsf

This comment has been minimized.

Contributor

mcsf commented Oct 15, 2018

I see the above is sort of tracked in #8180, so disregard. :)

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