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

fix(engine): prevent focus events when engine manages focus #1116

Merged
merged 2 commits into from
Mar 26, 2019

Conversation

ekashida
Copy link
Member

Details

Fixes issue #1031. Bubbling focus events (i.e. focusin and focusout) resulting from our synthetic delegatesFocus focus management were causing component event handlers to execute and getting us into an unexpected state. Since engine focus management should be transparent to components we should just mute them.

Does this PR introduce a breaking change?

  • Yes
  • No

@salesforce-best-lwc-internal

This comment has been minimized.

@salesforce-best-lwc-internal

This comment has been minimized.

@@ -302,20 +321,14 @@ function keyboardFocusInHandler(event: FocusEvent) {
const post = relatedTargetPosition(host as HTMLElement, relatedTarget);
switch (post) {
case 1: // focus is probably coming from above
if (
isFirstFocusableChildReceivingFocus &&
relatedTarget === getPreviousTabbableElement(segments)
Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like this change is the cause of the IE11 test failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

getPreviousTabbableElement is unreliable here since focusout is dispatched on the previous tabbable element before this focusin handler executes and the state of the DOM may change (e.g., the previously tabbable element is no longer tabbable). It seems that this check here is mainly to handle the case where the application focus enters the document? I'm not sure we can support both scenarios and I'm also not sure which scenario should take priority.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: b32da03 | Target commit: 75e1b88

lwc-engine-benchmark

table-append-1k metric base(b32da03) target(75e1b88) trend
benchmark-table/append/1k duration 151.45 (±5.35 ms) 148.00 (±4.15 ms) -3.4ms (2.3%) 👍
table-clear-1k metric base(b32da03) target(75e1b88) trend
benchmark-table/clear/1k duration 10.60 (±0.60 ms) 10.05 (±0.70 ms) -0.5ms (5.2%) 👍
table-create-10k metric base(b32da03) target(75e1b88) trend
benchmark-table/create/10k duration 897.10 (±8.20 ms) 883.20 (±4.60 ms) -13.9ms (1.5%) 👍
table-create-1k metric base(b32da03) target(75e1b88) trend
benchmark-table/create/1k duration 120.60 (±2.50 ms) 116.00 (±3.15 ms) -4.6ms (3.8%) 👍
table-update-10th-1k metric base(b32da03) target(75e1b88) trend
benchmark-table/update-10th/1k duration 75.40 (±3.10 ms) 83.80 (±2.80 ms) +8.4ms (11.1%) 👎
tablecmp-append-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-component/append/1k duration 224.40 (±8.30 ms) 225.50 (±12.45 ms) +1.1ms (0.5%) 👌
tablecmp-clear-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-component/clear/1k duration 5.60 (±0.80 ms) 5.75 (±1.05 ms) +0.2ms (2.7%) 👌
tablecmp-create-10k metric base(b32da03) target(75e1b88) trend
benchmark-table-component/create/10k duration 1775.70 (±11.75 ms) 1762.50 (±15.95 ms) -13.2ms (0.7%) 👍
tablecmp-create-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-component/create/1k duration 209.35 (±5.30 ms) 211.05 (±4.60 ms) +1.7ms (0.8%) 👌
tablecmp-update-10th-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-component/update-10th/1k duration 69.05 (±4.85 ms) 71.00 (±4.75 ms) +1.9ms (2.8%) 👌
wc-append-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-wc/append/1k duration 231.90 (±16.00 ms) 226.75 (±18.35 ms) -5.2ms (2.2%) 👌
wc-clear-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-wc/clear/1k duration 10.65 (±1.55 ms) 10.65 (±1.70 ms) 0.0ms (0.0%) 👌
wc-create-10k metric base(b32da03) target(75e1b88) trend
benchmark-table-wc/create/10k duration 1872.40 (±14.30 ms) 1845.25 (±10.65 ms) -27.2ms (1.5%) 👍
wc-create-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-wc/create/1k duration 220.30 (±5.25 ms) 222.05 (±3.95 ms) +1.8ms (0.8%) 👌
wc-update-10th-1k metric base(b32da03) target(75e1b88) trend
benchmark-table-wc/update-10th/1k duration 70.45 (±5.55 ms) 66.65 (±5.05 ms) -3.8ms (5.4%) 👍

Copy link
Contributor

@caridy caridy left a comment

Choose a reason for hiding this comment

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

LGTM, this is a clever idea.

@ekashida ekashida merged commit 477c5cf into master Mar 26, 2019
@ekashida ekashida deleted the ekashida/fixes-issue-1031 branch March 26, 2019 20:50
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.

2 participants