Skip to content

Block: Ignore focus if explicitOriginalTarget is not node (Firefox)#5112

Merged
mcsf merged 1 commit intomasterfrom
fix/focus-bubbling-firefox
Feb 16, 2018
Merged

Block: Ignore focus if explicitOriginalTarget is not node (Firefox)#5112
mcsf merged 1 commit intomasterfrom
fix/focus-bubbling-firefox

Conversation

@aduth
Copy link
Copy Markdown
Member

@aduth aduth commented Feb 16, 2018

This pull request seeks to resolve an issue where it is not possible to use the block toolbar for a nested block in Firefox. From what I've surmised, this is related to differing treatment of focus events and focus bubbling between Firefox and other browsers, and in its treatment of retargeting said events. My understanding is that IgnoreNestedEvents is not effective for preventing the focus event from surfacing to the ancestor block because it is already focused and is instead retargeted.

https://developer.mozilla.org/en-US/docs/Web/API/Event/explicitOriginalTarget

These changes detect the presence of this property and ensure that, if present, it is equal to the block node.

Testing instructions:

Verify that you can use the block toolbar, in Firefox and your preferred browser, for nested and non-nested blocks.

Verify that there are no regressions in the behavior of block selection via direct focus. Typically this can be done by tab navigating from one block to the next (e.g. a paragraph to a image placeholder block).

@aduth aduth added the [Type] Bug An existing feature does not function as intended label Feb 16, 2018
@aduth
Copy link
Copy Markdown
Member Author

aduth commented Feb 16, 2018

Potentially relevant:

When a focus or blur event crosses a scope boundary, the bound element is checked to see if it is focusable (i.e., if the user agent would normally fire a focus or blur event on the element). If the bound element is focusable, then the event is retargeted.

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XBL/XBL_1.0_Reference/Anonymous_Content#Focus_and_Blur_Events

Copy link
Copy Markdown
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I don't understand fully but the issue is fixed for me

@aduth
Copy link
Copy Markdown
Member Author

aduth commented Feb 16, 2018

Noted that an unrelated issue with Firefox remains after these changes: When navigating from a nested block to a non-nested block, the formatting toolbar options are not removed.

image

From what I was able to debug here, it seems the fill is being removed on its own unmount, but the slot is not found and therefore not forceUpdate'd afterward:

forceUpdateSlot( name ) {
const slot = this.getSlot( name );
if ( slot ) {
slot.forceUpdate();
}
}

@mcsf
Copy link
Copy Markdown
Contributor

mcsf commented Feb 16, 2018

Some impressive sleuthing.

Verify that you can use the block toolbar

It's not mentioned in the description, wondering if you also get the parent's outline:

1

Copy link
Copy Markdown
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

This moves us from "nesting is basically broken" to "it works but looks weird", which is apt for an experimental feature in such a large release. 🚢

@mcsf
Copy link
Copy Markdown
Contributor

mcsf commented Feb 16, 2018

I think we can address Safari separately.

@mcsf mcsf merged commit 5a89af4 into master Feb 16, 2018
@mcsf mcsf deleted the fix/focus-bubbling-firefox branch February 16, 2018 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants