Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1032)

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 2807653002: Ensure default dialog button focus remains after a dialog update. (Closed)
Patch Set: Addressing Devlin's comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/window/dialog_client_view.cc
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 5d543a7572efe2b85b8772f293c766cbdb19430f..e8c3838015e85c9ef1d79c1ce38ad4998a422b92 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -319,6 +319,7 @@ void DialogClientView::SetupLayout() {
base::AutoReset<bool> auto_reset(&adding_or_removing_views_, true);
GridLayout* layout = new GridLayout(button_row_container_);
layout->set_minimum_size(minimum_size_);
+ default_focus_ = GetDialogDelegate()->GetInitiallyFocusedView();
sky 2017/04/28 20:49:52 There should be no need for the member as it's onl
ackermanb 2017/05/17 17:20:54 Done.
// Clobber any existing LayoutManager since it has weak references to child
// Views which may be removed by SetupViews().
@@ -399,6 +400,12 @@ void DialogClientView::SetupLayout() {
column_set->LinkColumnSizes(link[0], link[1], link[2], -1);
}
layout->AddPaddingRow(kFixed, insets.bottom());
+
+ // The default focus is lost when child views are added back into the dialog.
+ // This restores focus to the default.
+ if (default_focus_) {
+ default_focus_->RequestFocus();
+ }
}
void DialogClientView::SetupViews() {

Powered by Google App Engine
This is Rietveld 408576698