WebKit Bugzilla
Attachment 348216 Details for
Bug 189010
: [Datalist] Pressing enter without a selected option shouldn't change the input
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189010-20180827153302.patch (text/plain), 6.18 KB, created by
Aditya Keerthi
on 2018-08-27 15:33:03 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-08-27 15:33:03 PDT
Size:
6.18 KB
patch
obsolete
>Subversion Revision: 235403 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 63ada764cf062b292a89fa06ba5161e614140418..e7188d541b57c2465cb656c9718e0cb38c4be48a 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,29 @@ >+2018-08-27 Aditya Keerthi <akeerthi@apple.com> >+ >+ [Datalist] Pressing enter without a selected option shouldn't change the input >+ https://bugs.webkit.org/show_bug.cgi?id=189010 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Currently, the value of an input field gets cleared if there is no selected >+ datalist suggestion when the enter key is pressed. The correct behavior is to >+ leave the value of the input as-is. >+ >+ The incorrect behavior is a consequence of the fact that an empty string is >+ returned by [WKDataListSuggestionsView currentSelectedString] if there is no >+ selection. To fix the behavior, the method now returns an std::optional instead >+ of an empty string. If std::nullopt is returned, we do not make any modification >+ to the value of the input. This ensures that we can still change the value of >+ an input field to an empty string in the case that an empty string is part of >+ the suggestions. >+ >+ Augmented test: fast/forms/datalist/datalist-textinput-keydown.html >+ >+ * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm: >+ (WebKit::WebDataListSuggestionsDropdownMac::selectOption): >+ (-[WKDataListSuggestionCell drawRect:]): Quick fix. The mouseover color was incorrect. >+ (-[WKDataListSuggestionsView currentSelectedString]): >+ > 2018-08-27 Aditya Keerthi <akeerthi@apple.com> > > Consolidate ENABLE_INPUT_TYPE_COLOR and ENABLE_INPUT_TYPE_COLOR_POPOVER >diff --git a/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm b/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm >index 1a4f60af531dd00316ec4a5ead441332f9d316f1..31481d0dad5938778245580a9b846f160781d057 100644 >--- a/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm >+++ b/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm >@@ -77,7 +77,7 @@ static NSString * const suggestionCellReuseIdentifier = @"WKDataListSuggestionCe > - (void)moveSelectionByDirection:(const String&)direction; > - (void)invalidate; > >-- (String)currentSelectedString; >+- (std::optional<String>)currentSelectedString; > @end > > namespace WebKit { >@@ -120,8 +120,10 @@ void WebDataListSuggestionsDropdownMac::selectOption() > if (!m_client) > return; > >- String selectedOption = [m_dropdownUI currentSelectedString]; >- m_client->didSelectOption(selectedOption); >+ std::optional<String> selectedOption = [m_dropdownUI currentSelectedString]; >+ if (selectedOption) >+ m_client->didSelectOption(selectedOption.value()); >+ > close(); > } > >@@ -189,7 +191,7 @@ void WebDataListSuggestionsDropdownMac::close() > [[NSColor alternateSelectedControlColor] setFill]; > [_textField setTextColor:[NSColor alternateSelectedControlTextColor]]; > } else if (_mouseIsOver) { >- [[NSColor controlColor] setFill]; >+ [[NSColor quaternaryLabelColor] setFill]; > [_textField setTextColor:[NSColor textColor]]; > } else { > [[NSColor controlBackgroundColor] setFill]; >@@ -327,13 +329,13 @@ void WebDataListSuggestionsDropdownMac::close() > return self; > } > >-- (String)currentSelectedString >+- (std::optional<String>)currentSelectedString > { > std::optional<size_t> selectedRow = [_table currentActiveRow]; > if (selectedRow && selectedRow.value() < _suggestions.size()) > return _suggestions.at(selectedRow.value()); > >- return emptyString(); >+ return std::nullopt; > } > > - (void)updateWithInformation:(WebCore::DataListSuggestionInformation&&)information >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index cc4adee92b9903207db44ab7ff064d17108742a0..0a970dfd7990fb082b85967dcd61075ef7456afe 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2018-08-27 Aditya Keerthi <akeerthi@apple.com> >+ >+ [Datalist] Pressing enter without a selected option shouldn't change the input >+ https://bugs.webkit.org/show_bug.cgi?id=189010 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Augmented test to verify that pressing enter when there is no selected datalist >+ suggestion does not change the value of the input field. >+ >+ * fast/forms/datalist/datalist-textinput-keydown-expected.txt: >+ * fast/forms/datalist/datalist-textinput-keydown.html: >+ > 2018-08-27 Andy Estes <aestes@apple.com> > > [Payment Request] Update payment-request web platform tests >diff --git a/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt >index 4ac50d6ab9b782d57584bb6703d596429af7e88f..886ad61ac33a16cbba7bb8a4d50fc8dcab3040dd 100644 >--- a/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt >+++ b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt >@@ -5,6 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE > > PASS input.value is "Apple" > PASS input.value is "Pear" >+PASS input.value is "Appl" > PASS successfullyParsed is true > > TEST COMPLETE >diff --git a/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html >index 33468926678ab58a6ae457a9b3b15c69b7108407..22c488dfe9b929327df28f525025bcc6f69f0cfb 100644 >--- a/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html >+++ b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html >@@ -22,7 +22,6 @@ var input = document.getElementById("fruit"); > UIHelper.activateElement(input); > eventSender.keyDown("downArrow"); > eventSender.keyDown("\r"); >- > shouldBe('input.value', '"Apple"'); > > input.value = ""; >@@ -30,9 +29,14 @@ input.value = ""; > UIHelper.activateElement(input); > eventSender.keyDown("upArrow"); > eventSender.keyDown("\r"); >- > shouldBe('input.value', '"Pear"'); > >+input.value = "Appl"; >+ >+UIHelper.activateElement(input); >+eventSender.keyDown("\r"); >+shouldBe('input.value', '"Appl"'); >+ > </script> > > <script src="../../../resources/js-test-post.js"></script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189010
: 348216