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

Apply block order by Flexbox order property #563

Closed
wants to merge 1 commit into from

Conversation

aduth
Copy link
Member

@aduth aduth commented Apr 28, 2017

Fixes #544

This pull request seeks to implement an unfortunate but surprisingly reasonable hack to resolve iframe flickering of embed blocks using Flexbox's order property instead of natural DOM ordering. The default behavior of moving an iframe in a DOM results in the iframe being reloaded. The effect here is to never rearrange the DOM position but instead affect ordering through the order styling. From a user's perspective, there should be no difference.

See also:

Minimal proof-of-concept:

Testing instructions:

Repeat steps to reproduce from #544, verifying that neither moving the embed up nor down results in a flickering reload of the iframe.

@aduth aduth added the [Feature] Blocks Overall functionality of blocks label Apr 28, 2017
@aduth aduth changed the title Apply order by Flexbox order property Apply block order by Flexbox order property Apr 28, 2017
@ellatrix
Copy link
Member

Works great! Really cool ✨

@@ -10,17 +11,23 @@ import './style.scss';
import Inserter from 'components/inserter';
import VisualEditorBlock from './block';

function VisualEditor( { blocks } ) {
function VisualEditor( { blocks, blockOrder } ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

blockOrder is not being use in this component, shoud we move it the the connect of the VisualEditorBlock component?

Copy link
Member Author

@aduth aduth May 1, 2017

Choose a reason for hiding this comment

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

blockOrder is not being use in this component, shoud we move it the the connect of the VisualEditorBlock component?

Yep! And in fact, the order prop is already specified in block.js's connect, so just need to remove this. See f86de14.

@jasmussen
Copy link
Contributor

This is mindblowing. 💥

@aduth
Copy link
Member Author

aduth commented May 1, 2017

So there appears to be some accessibility implications on this, since tabbing will not respect order but instead the element occurrence in the DOM. My first thought was to provide a specific tabIndex correlating to the block's order as defined in editor state (see 290314c), but there are two issues here:

  • Previously we used tabIndex="0" to define the block as focusable but leave it to the browser to determine order based on element position. Now that we're providing positive, non-zero numbers, we may be impacting focus order of other elements on the page (sidebar, admin bar, etc). This seems undesirable, or at least hard to manage.
  • Tab behavior doesn't seem to always respect tabIndex if there's a focusable element as a descendent of the next element in the DOM.

To illustrate the second point, try the following steps:

  • Move the last embed block up
  • Select the text block before the embed block (starting "By shipping early")
  • Press tab

Expected: Focus moved to embed block
Actual: Focus moved to list block

It's not clear to me why this is; I'm wondering if TinyMCE is hijacking the focus change. In my minimal proof of concept, it seems like tabbing should respect tabindex regardless of whether there are focusable elements in the element between.

@jasmussen
Copy link
Contributor

So there appears to be some accessibility implications on this

Forgive me for asking what I know will sound somewhat silly; what if as soon as you press tab, after having rearranged boxes with the arrows, we actually reorder the markup and allow the repaint to happen? This is based on the assumption that people won't necessarily be tabbing around that often, and when they do a single repaint in the edgecases where necessary will be an okay tradeoff.

@aduth
Copy link
Member Author

aduth commented May 2, 2017

I don't know for certain that we have access to control the tabindex behavior on the fly like this, since it sounds like we'd need to intercept the tab key event, rearrange the DOM, then allow the key event to proceed with its default behavior.

@aduth
Copy link
Member Author

aduth commented May 23, 2017

Closing in response to accessibility concerns outlined at #544 (comment).

@aduth aduth closed this May 23, 2017
@aduth aduth deleted the fix/544-embed-flicker branch May 23, 2017 19:15
@jasmussen
Copy link
Contributor

Thanks for trying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moving a block down forces a re-render
4 participants