Commit e0c414fe authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Revert "Files app: Force focus out of <body>"

This reverts commit 2bbea72b.

Reason for revert: caused regression shown in crbug.com/1060527

Original change's description:
> Files app: Force focus out of <body>
>
> When the element has the focus is hidden/removed/disabled the browser
> moves the focus to <body>, in this situation user doesn't have any
> visual clue where is the focus. To fix this we move the focus from
> <body> to file list which is the default element when opening Files app.
>
> Use "focusin" and "focusout" in the <body> element, because these two
> events bubble from any body's child element, whereas "focus" event
> doesn't. In the event handler we use requestIdleCallback() to give a
> chance for any synchronous code to finish and potentially set the focus
> somewhere else other than <body>.
>
> Test: browser_tests --gtest_filter="*tabindexFocusBody*"
> Bug: 1059137,957413
> Change-Id: I9563294a3b6c541cf6bd2bba03470041bc8af41b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089444
> Reviewed-by: Noel Gordon <noel@chromium.org>
> Reviewed-by: Alex Danilo <adanilo@chromium.org>
> Commit-Queue: Noel Gordon <noel@chromium.org>
> Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#748090}

TBR=noel@chromium.org,lucmult@chromium.org,adanilo@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1059137, 957413, 1060527
Change-Id: I52e68555b814172d532202631269c676ec9c15ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100050
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749550}
parent 662d6c19
...@@ -723,8 +723,6 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -723,8 +723,6 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
::testing::Values( ::testing::Values(
TestCase("tabindexSearchBoxFocus").FilesNg(), TestCase("tabindexSearchBoxFocus").FilesNg(),
TestCase("tabindexSearchBoxFocus").DisableFilesNg(), TestCase("tabindexSearchBoxFocus").DisableFilesNg(),
TestCase("tabindexFocusBody").DisableFilesNg(),
TestCase("tabindexFocusBody").FilesNg(),
TestCase("tabindexFocus").DisableFilesNg(), TestCase("tabindexFocus").DisableFilesNg(),
TestCase("tabindexFocusDownloads").FilesNg(), TestCase("tabindexFocusDownloads").FilesNg(),
TestCase("tabindexFocusDownloads").DisableFilesNg(), TestCase("tabindexFocusDownloads").DisableFilesNg(),
......
...@@ -400,9 +400,6 @@ class FileManagerUI { ...@@ -400,9 +400,6 @@ class FileManagerUI {
e.stopPropagation(); e.stopPropagation();
}); });
} }
/** @private {?number} */
this.focusBodyCallbackId_ = null;
} }
/** /**
...@@ -454,31 +451,6 @@ class FileManagerUI { ...@@ -454,31 +451,6 @@ class FileManagerUI {
if (targetElement) { if (targetElement) {
targetElement.focus(); targetElement.focus();
} }
/** If focus lands in the <body> we move to the file list. */
const focusList = () => {
if (this.focusBodyCallbackId_) {
return;
}
this.focusBodyCallbackId_ = window.requestIdleCallback(() => {
if (document.activeElement &&
document.activeElement.tagName === 'BODY') {
this.focusDefaultElement_();
}
this.focusBodyCallbackId_ = null;
});
};
document.body.addEventListener('focusin', focusList);
document.body.addEventListener('focusout', focusList);
}
/**
* Sets the focus in the default UI element.
* @private
*/
focusDefaultElement_() {
this.listContainer.currentList && this.listContainer.currentList.focus();
} }
/** /**
......
...@@ -401,20 +401,3 @@ testcase.tabindexSaveFileDialogDrive = async () => { ...@@ -401,20 +401,3 @@ testcase.tabindexSaveFileDialogDrive = async () => {
'new-folder-button', 'filename-input-textbox' 'new-folder-button', 'filename-input-textbox'
]); ]);
}; };
/**
* Tests that focus doesn't stay on <body>, it's moved to the file list.
*/
testcase.tabindexFocusBody = async () => {
// Open Files app on Downloads.
const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS);
// Check that the file list.
await remoteCall.waitForElement(appId, ['#file-list:focus']);
// Force focus on <body>.
await remoteCall.focus(appId, ['body']);
// Check that the file list.
await remoteCall.waitForElement(appId, ['#file-list:focus']);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment