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

Blocks: Avoid autofocus behavior for blocks without focusable elements #5110

Merged
merged 4 commits into from
Feb 16, 2018

Conversation

youknowriad
Copy link
Contributor

Avoid auto-focusing blocks without any tabbable element.

@youknowriad youknowriad self-assigned this Feb 16, 2018
@mcsf
Copy link
Contributor

mcsf commented Feb 16, 2018

I don't know about others, but now I believe that some of the reproduced instances were false-positives: if the user moves the cursor ever so briefly (imperceptibly so) between clicking and releasing the click, the whole block is selected. Happens both in base and branch.

@youknowriad
Copy link
Contributor Author

Good find @mcsf this hints that the remaining issue is related to multi-selection :)

@mcsf
Copy link
Contributor

mcsf commented Feb 16, 2018

:) That said, there are some occurrences that this PR does fix, so let's merge it!

Steps:

  1. Open demo
  2. Scroll all the way up
  3. Focus title
  4. Scroll down until first Image block partly visible
  5. Click it

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the problem in my tests.

@youknowriad youknowriad merged commit eeba954 into master Feb 16, 2018
@youknowriad youknowriad deleted the fix/selecting-image-gallery-blocks branch February 16, 2018 19:22
@@ -218,7 +218,8 @@ export class BlockListBlock extends Component {
}

// Find all tabbables within node.
const tabbables = focus.tabbable.find( this.node );
const tabbables = focus.tabbable.find( this.node )
.filter( ( node ) => node !== this.node );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure when this could be the case? Following the logic, find will call querySelectorAll, which shouldn't include the source node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants