Commit 32c411ac authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Focus inline reply field on button click.

In NotificationViewMD, the inline reply field will be shown when
a configured button in a notification is clicked.

The intended behavior is to focus on inline reply after the button
is clicked, but RequestFocus was called before SetVisible(true),
which is no-op.

You can test the feature by enabling
chrome://flags/#enable-experimental-web-platform-features then
https://tests.peter.sh/notification-generator/ ->
Actions -> "One action (type text)" -> Display the notification.

TEST=NotificationViewMDTest.TestInlineReply
BUG=845189

Change-Id: I1f5d80ad1ab20b7061621fdc6ab8745c7c4ecfea
Reviewed-on: https://chromium-review.googlesource.com/1068529
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560919}
parent cdb58d35
...@@ -788,10 +788,11 @@ void NotificationViewMD::ButtonPressed(views::Button* sender, ...@@ -788,10 +788,11 @@ void NotificationViewMD::ButtonPressed(views::Button* sender,
inline_reply_->textfield()->set_index(i); inline_reply_->textfield()->set_index(i);
inline_reply_->textfield()->set_placeholder( inline_reply_->textfield()->set_placeholder(
*action_buttons_[i]->placeholder()); *action_buttons_[i]->placeholder());
inline_reply_->textfield()->RequestFocus();
inline_reply_->AnimateBackground(*event.AsLocatedEvent()); inline_reply_->AnimateBackground(*event.AsLocatedEvent());
inline_reply_->SetVisible(true); inline_reply_->SetVisible(true);
action_buttons_row_->SetVisible(false); action_buttons_row_->SetVisible(false);
// RequestFocus() should be called after SetVisible().
inline_reply_->textfield()->RequestFocus();
Layout(); Layout();
SchedulePaint(); SchedulePaint();
} else { } else {
......
...@@ -499,8 +499,7 @@ TEST_F(NotificationViewMDTest, TestInlineReply) { ...@@ -499,8 +499,7 @@ TEST_F(NotificationViewMDTest, TestInlineReply) {
notification_view()->ToggleExpanded(); notification_view()->ToggleExpanded();
EXPECT_FALSE(notification_view()->inline_reply_->visible()); EXPECT_FALSE(notification_view()->inline_reply_->visible());
// Click the button again and focus on the inline textfield. // Click the button again and the inline textfield should be focused.
generator.ClickLeftButton();
generator.ClickLeftButton(); generator.ClickLeftButton();
EXPECT_TRUE(notification_view()->inline_reply_->visible()); EXPECT_TRUE(notification_view()->inline_reply_->visible());
EXPECT_TRUE(notification_view()->inline_reply_->textfield()->visible()); EXPECT_TRUE(notification_view()->inline_reply_->textfield()->visible());
......
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