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 meta+A behaviour of selecting all blocks work on safari and firefox #8180

Merged
merged 1 commit into from Nov 1, 2018

Conversation

Projects
None yet
4 participants
@jorgefilipecosta
Member

jorgefilipecosta commented Jul 24, 2018

On safari and firefox isEntirelySelected( target ) called right after meta+A event is fired when meta key is not released in the middle returns false but the content gets selected anyway.
If the target is editable it is safe to assume TinyMCE will make sure all content gets selected so in this cases we set the value to true without calling isEntirelySelected.

Fixes: #7445

How has this been tested?

I added some paragraphs.
On safari and firefox, I checked that when we press meta+A in paragraph two times all the blocks get selected.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/meta-A-select-all-blocks-accross-browsers branch from 5a320d4 to 4503511 Aug 1, 2018

@jorgefilipecosta jorgefilipecosta requested a review from WordPress/gutenberg-core Aug 17, 2018

@jorgefilipecosta jorgefilipecosta force-pushed the fix/meta-A-select-all-blocks-accross-browsers branch from 4503511 to 0372e34 Aug 17, 2018

@noisysocks

I've tested this in Chrome, Firefox, Safari, Edge, and IE 11 and the bug is fixed 👍

Might be good to get another pair of eyes on this since I'm not 100% on how it works.

// but on some browsers (safari and firefox) calling isEntirelySelected right way still returns false.
// So to make sure we are compatible with this browsers we set is entirely selected to true
// after the first meta+a keypress assuming TinyMCE will make all content entirely selected.
this.isEntirelySelected = target.isContentEditable ? true : isEntirelySelected( target );

This comment has been minimized.

@noisysocks

noisysocks Aug 20, 2018

Member

I'm trying to wrap my head around this logic. When would primary+a not result in all of the text being selected? In other words, why can't this line be:

this.isEntirelySelected = true;

This comment has been minimized.

@aduth

aduth Aug 20, 2018

Member

I'm very hesitant of anything which forks logic based on browser differences. Can we simplify to what @noisysocks said? Should that live in isEntirelySelected ? Do we need isEntirelySelected at all? What is it about being isContentEditable that makes us assume it's entirely selected?

// but on some browsers (safari and firefox) calling isEntirelySelected right way still returns false.
// So to make sure we are compatible with this browsers we set is entirely selected to true
// after the first meta+a keypress assuming TinyMCE will make all content entirely selected.
this.isEntirelySelected = target.isContentEditable ? true : isEntirelySelected( target );

This comment has been minimized.

@aduth

aduth Aug 20, 2018

Member

I'm very hesitant of anything which forks logic based on browser differences. Can we simplify to what @noisysocks said? Should that live in isEntirelySelected ? Do we need isEntirelySelected at all? What is it about being isContentEditable that makes us assume it's entirely selected?

@jorgefilipecosta jorgefilipecosta force-pushed the fix/meta-A-select-all-blocks-accross-browsers branch from 0372e34 to 5e4d8dc Aug 22, 2018

@jorgefilipecosta

This comment has been minimized.

Member

jorgefilipecosta commented Aug 22, 2018

Hi @aduth, @noisysocks I checked that in fact, we could simplify the logic to what @noisysocks said.
The isEntirelySelected function returns true if it is called on a non-content editable. Given that for contenEidtables we know that when we press primary + A the content gets selected I think we can safely simplify the logic to just set the flag to true after primary + A is pressed.

I think the feedback was addressed and the code was simplified to the solution proposed by @noisysocks.

Fix: make meta+A behaviour of selecting all blocks work on safari and…
… firefox.

On safari and firefox isEntirelySelected( target ) called right after meta+A event is fired without releasing the meta key in the middle returns false but content gets selected anyway. If the target is editable it is safe to assume TinyMCE will make sure all content gets selected so in this cases we set the value to true without calling isEntirelySelected.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/meta-A-select-all-blocks-accross-browsers branch from 5e4d8dc to 56819c6 Nov 1, 2018

@jorgefilipecosta jorgefilipecosta added this to the 4.3 milestone Nov 1, 2018

@jorgefilipecosta jorgefilipecosta merged commit b3e0e89 into master Nov 1, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/meta-A-select-all-blocks-accross-browsers branch Nov 1, 2018

daniloercoli added a commit that referenced this pull request Nov 1, 2018

Merge branch 'master' of https://github.com/WordPress/gutenberg into …
…rnmobile/port-quote-block-step-1

* 'master' of https://github.com/WordPress/gutenberg: (22 commits)
  Add removed periods to block descriptions. (#11367)
  Remove findDOMNode usage from the inserter (#11363)
  Remove deprecated componentWillReceiveProps from TinyMCE component (#11368)
  Create file blocks when dropping multiple files at once (#11297)
  Try avoiding the deprecated findDOMNode API from DropZone Provider (#11168)
  Fix: make meta+A behaviour of selecting all blocks work on safari and firefox. (#8180)
  Remove _wpGutenbergCodeEditorSettings and wp.codeEditor assets (#11342)
  Remove the Cloudflare warning (#11350)
  Image Block: Use source_url for media file link (#11254)
  Enhance styling of nextpage block using the Hr element (#11354)
  Embed block refactor and tidy (#10958)
  Nonce Middleware: Wrap the nonce middleware function into it's own function that isn't regenerated on every API request. (#11347)
  Fix RTL block alignments (#11293)
  RichText: fix buggy enter/delete behaviour (#11287)
  Remove code coverage setup (#11198)
  Parser: Runs all parser implementations against the same tests (#11320)
  Stop trying to autosave when title and classic block content both are empty. (#10404)
  Fix "Mac OS" typo + use fancy quotes consistently (#11310)
  Update documentation link paths (#11324)
  Editor: Reshape blocks state under own key (#11315)
  ...

# Conflicts:
#	gutenberg-mobile

antpb added a commit to antpb/gutenberg that referenced this pull request Nov 5, 2018

Fix: make meta+A behaviour of selecting all blocks work on safari and…
… firefox. (WordPress#8180)

On safari and firefox isEntirelySelected( target ) called right after meta+A event is fired when meta key is not released in the middle returns false but the content gets selected anyway.
If the target is editable it is safe to assume TinyMCE will make sure all content gets selected so in this cases we set the value to true without calling isEntirelySelected.

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Nov 22, 2018

Fix: make meta+A behaviour of selecting all blocks work on safari and…
… firefox. (WordPress#8180)

On safari and firefox isEntirelySelected( target ) called right after meta+A event is fired when meta key is not released in the middle returns false but the content gets selected anyway.
If the target is editable it is safe to assume TinyMCE will make sure all content gets selected so in this cases we set the value to true without calling isEntirelySelected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment