Skip to content

Commit f8d73db

Browse files
author
stkhapugin@chromium.org
committed
Update omnibox clear button visibility on focus.
Monitor omnibox focus notification to update the clear button visibility on focus. Bug: 866446, 865019, 865013, 864511 Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet Change-Id: Iecf54d4550e4c6fe3f3988a54602c4d32d417f89 Reviewed-on: https://chromium-review.googlesource.com/1143860 Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org> Reviewed-by: Rohit Rao <rohitrao@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#577161}(cherry picked from commit 06ea7b0) Reviewed-on: https://chromium-review.googlesource.com/1150100 Reviewed-by: Stepan Khapugin <stkhapugin@chromium.org> Cr-Commit-Position: refs/branch-heads/3497@{#66} Cr-Branched-From: 271eaf5-refs/heads/master@{#576753}
1 parent 4745a26 commit f8d73db

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ios/chrome/browser/ui/omnibox/omnibox_view_controller.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ - (void)viewDidLoad {
7575
self.textField.placeholderTextColor = [self placeholderAndClearButtonColor];
7676
self.textField.placeholder = l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT);
7777
[self setupClearButton];
78+
79+
// TODO(crbug.com/866446): Use UITextFieldDelegate instead.
80+
[[NSNotificationCenter defaultCenter]
81+
addObserver:self
82+
selector:@selector(textFieldDidBeginEditing)
83+
name:UITextFieldTextDidBeginEditingNotification
84+
object:self.textField];
7885
}
7986

8087
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
@@ -112,6 +119,14 @@ - (UIColor*)placeholderAndClearButtonColor {
112119
: [UIColor colorWithWhite:0 alpha:0.3];
113120
}
114121

122+
#pragma mark notification callbacks
123+
124+
// Called on UITextFieldTextDidBeginEditingNotification for self.textField.
125+
- (void)textFieldDidBeginEditing {
126+
// Update the clear button state.
127+
[self updateClearButtonVisibility];
128+
}
129+
115130
#pragma mark clear button
116131

117132
// Omnibox uses a custom clear button. It has a custom tint and image, but

0 commit comments

Comments
 (0)