Commit 1c49d171 authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Local NTP: only show "Remove suggestion" (X) on hover

* Show X on row hover
* Show (X) (background) on icon hover
* Reserve space if any 1+ matches are removable

Fixed: 1002689
Change-Id: Idd1f4a623e013893d6e376eedaff3ea2ee26fdc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842622
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704304}
parent 6023131a
...@@ -236,7 +236,7 @@ body.hide-fakebox #fakebox { ...@@ -236,7 +236,7 @@ body.hide-fakebox #fakebox {
background-position-x: calc(100% - 16px); background-position-x: calc(100% - 16px);
} }
#realbox-matches a.removable { #realbox-matches.removable a {
padding-inline-end: 48px; padding-inline-end: 48px;
} }
...@@ -304,15 +304,16 @@ html[dir=rtl] #realbox-matches .clock-icon { ...@@ -304,15 +304,16 @@ html[dir=rtl] #realbox-matches .clock-icon {
} }
#realbox-matches .remove-icon { #realbox-matches .remove-icon {
-webkit-appearance: none; height: 100%;
width: 100%;
}
#realbox-matches a:-webkit-any(:hover, :focus-within) .remove-icon {
-webkit-mask-image: url(../../../../ui/webui/resources/images/icon_clear.svg); -webkit-mask-image: url(../../../../ui/webui/resources/images/icon_clear.svg);
-webkit-mask-position: center; -webkit-mask-position: center;
-webkit-mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat;
-webkit-mask-size: 16px; -webkit-mask-size: 16px;
background-color: rgb(var(--GG900-rgb)); background-color: rgb(var(--GG900-rgb));
border: none;
height: 100%;
width: 100%;
} }
#fakebox > input { #fakebox > input {
...@@ -837,13 +838,11 @@ html[dir=rtl] #error-notice.has-link #error-notice-msg { ...@@ -837,13 +838,11 @@ html[dir=rtl] #error-notice.has-link #error-notice-msg {
} }
#promo > div .dismiss-icon { #promo > div .dismiss-icon {
-webkit-appearance: none;
-webkit-mask-image: url(../../../../ui/webui/resources/images/icon_clear.svg); -webkit-mask-image: url(../../../../ui/webui/resources/images/icon_clear.svg);
-webkit-mask-position: center center; -webkit-mask-position: center center;
-webkit-mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat;
-webkit-mask-size: 16px; -webkit-mask-size: 16px;
background-color: rgb(var(--dismiss-background-rgb)); background-color: rgb(var(--dismiss-background-rgb));
border: none;
display: block; display: block;
height: 100%; height: 100%;
outline: none; outline: none;
......
...@@ -1448,7 +1448,7 @@ function populateAutocompleteMatches(matches) { ...@@ -1448,7 +1448,7 @@ function populateAutocompleteMatches(matches) {
remove.appendChild(icon); remove.appendChild(icon);
matchEl.appendChild(remove); matchEl.appendChild(remove);
matchEl.classList.add(CLASSES.REMOVABLE); realboxMatchesEl.classList.add(CLASSES.REMOVABLE);
} }
// TODO(crbug.com/1002689): set a more useful aria-label on |matchEl|, as // TODO(crbug.com/1002689): set a more useful aria-label on |matchEl|, as
......
...@@ -19,6 +19,7 @@ test.realbox.IDS = { ...@@ -19,6 +19,7 @@ test.realbox.IDS = {
* @const * @const
*/ */
test.realbox.CLASSES = { test.realbox.CLASSES = {
REMOVABLE: 'removable',
REMOVE_ICON: 'remove-icon', REMOVE_ICON: 'remove-icon',
SELECTED: 'selected', SELECTED: 'selected',
SHOW_MATCHES: 'show-matches', SHOW_MATCHES: 'show-matches',
...@@ -513,6 +514,9 @@ test.realbox.testUnsupportedDeletion = function() { ...@@ -513,6 +514,9 @@ test.realbox.testUnsupportedDeletion = function() {
test.realbox.realboxEl.dispatchEvent(keyEvent); test.realbox.realboxEl.dispatchEvent(keyEvent);
assertFalse(keyEvent.defaultPrevented); assertFalse(keyEvent.defaultPrevented);
const matchesEl = $(test.realbox.IDS.REALBOX_MATCHES);
assertFalse(matchesEl.classList.contains(test.realbox.CLASSES.REMOVABLE));
// The below 2 statements shouldn't really happen in updated code but isn't // The below 2 statements shouldn't really happen in updated code but isn't
// terrible idea to keep testing for now. This is because SupportsDeletion() // terrible idea to keep testing for now. This is because SupportsDeletion()
// is now propagated to the client, so we shouldn't allow users (via the UI) // is now propagated to the client, so we shouldn't allow users (via the UI)
...@@ -533,6 +537,9 @@ test.realbox.testSupportedDeletion = function() { ...@@ -533,6 +537,9 @@ test.realbox.testSupportedDeletion = function() {
chrome.embeddedSearch.searchBox.onqueryautocompletedone( chrome.embeddedSearch.searchBox.onqueryautocompletedone(
{input: test.realbox.realboxEl.value, matches}); {input: test.realbox.realboxEl.value, matches});
const matchesEl = $(test.realbox.IDS.REALBOX_MATCHES);
assertTrue(matchesEl.classList.contains(test.realbox.CLASSES.REMOVABLE));
const downArrow = new KeyboardEvent('keydown', { const downArrow = new KeyboardEvent('keydown', {
bubbles: true, bubbles: true,
cancelable: true, cancelable: true,
...@@ -541,9 +548,9 @@ test.realbox.testSupportedDeletion = function() { ...@@ -541,9 +548,9 @@ test.realbox.testSupportedDeletion = function() {
test.realbox.realboxEl.dispatchEvent(downArrow); test.realbox.realboxEl.dispatchEvent(downArrow);
assertTrue(downArrow.defaultPrevented); assertTrue(downArrow.defaultPrevented);
const matchEls = $(test.realbox.IDS.REALBOX_MATCHES).children; assertEquals(2, matchesEl.children.length);
assertEquals(2, matchEls.length); assertTrue(
assertTrue(matchEls[1].classList.contains(test.realbox.CLASSES.SELECTED)); matchesEl.children[1].classList.contains(test.realbox.CLASSES.SELECTED));
const shiftDelete = new KeyboardEvent('keydown', { const shiftDelete = new KeyboardEvent('keydown', {
bubbles: true, bubbles: true,
...@@ -571,9 +578,10 @@ test.realbox.testRemoveIcon = function() { ...@@ -571,9 +578,10 @@ test.realbox.testRemoveIcon = function() {
chrome.embeddedSearch.searchBox.onqueryautocompletedone( chrome.embeddedSearch.searchBox.onqueryautocompletedone(
{input: test.realbox.realboxEl.value, matches}); {input: test.realbox.realboxEl.value, matches});
const sel = `#${test.realbox.IDS.REALBOX_MATCHES} const matchesEl = $(test.realbox.IDS.REALBOX_MATCHES);
.${test.realbox.CLASSES.REMOVE_ICON}`; assertTrue(matchesEl.classList.contains(test.realbox.CLASSES.REMOVABLE));
document.querySelector(sel).click();
matchesEl.querySelector(`.${test.realbox.CLASSES.REMOVE_ICON}`).click();
assertEquals(1, test.realbox.deletedLines.length); assertEquals(1, test.realbox.deletedLines.length);
assertEquals(0, test.realbox.deletedLines[0]); assertEquals(0, test.realbox.deletedLines[0]);
......
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