mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: add focusOnNavigation flag to WebPreferences (#49512)
* feat: add focusOnNavigation webPreference Co-authored-by: Kyle Cutler <kycutler@microsoft.com> * WebContentsView tests Co-authored-by: Kyle Cutler <kycutler@microsoft.com> * fix Co-authored-by: Kyle Cutler <kycutler@microsoft.com> * fix Co-authored-by: Kyle Cutler <kycutler@microsoft.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Kyle Cutler <kycutler@microsoft.com>
This commit is contained in:
@@ -2065,6 +2065,10 @@ void WebContents::ReadyToCommitNavigation(
|
||||
// Only focus for top-level contents.
|
||||
if (type_ != Type::kBrowserWindow)
|
||||
return;
|
||||
// Don't focus if focusOnNavigation is disabled.
|
||||
auto* prefs = WebContentsPreferences::From(web_contents());
|
||||
if (prefs && !prefs->ShouldFocusOnNavigation())
|
||||
return;
|
||||
web_contents()->SetInitialFocus();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user