-
Notifications
You must be signed in to change notification settings - Fork 846
Instant Search: change visual on close button #14680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instant Search: change visual on close button #14680
Conversation
|
@keoshi This is gunna sound crazy, but on larger screens (15 inch macbook) the X icon is way far away. I'm wondering if it's too far. If I sound crazy, ignore me. Otherwise, I'm wondering if there's a way to max the distance from the search results / widgets? More importantly, the div looks good, but it's not visually selectable when I use |
jsnmoon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the rationale for the change. However, it looks like the close button becomes invisible in two scenarios:
- When using the dark theme (screenshot omitted)
- On viewports narrower than the 768 breakpoint:
I also agree with @jeffgolenski's suggestion on bringing the close button closer to the sidebar area.
| <button | ||
| <div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Changing a div to button, even when given a button role, decreases accessibility. Are we doing this to avoid styling issues from the theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. Since almost all themes include default styling for the button element it would be very hard for us to target it in order to remove all styling.
For example, Twenty Twenty targets it as button:not(.toggle) which is highly specific and nearly impossible to target, even with a narrow button.jetpack-instant-search__overlay-close.
To be clear though, I've transformed it into a div because that's what my skills allowed me to do. I imagine a link (a) would be a better fit, but it requires more wiring and functions that I could do on friday.
|
@jeffgolenski Great feedback! I'll try to see if I can include the close button on a wrapping div. As for
You should be able to select it by navigating with the tab key; that's what this line is for: |
|
@jsnmoon Yep, I still have to add styles for the dark variant. Thanks for catching all those scenarios, will get started on those right away. |
|
@jsnmoon Updated this PR but I couldn't do it all so it still needs some work. I brought in the close button from I've added a temporary placeholder here so I could test it without errors: https://github.com/Automattic/jetpack/pull/14680/files#diff-577c3009c4d36d28fd2e71d0adb283d8R146 Let me know if this is an efficient use of both of our time, or if you'd prefer to handle these on your own. And apologies in advance if the code is not up to par. |
|
Seems good. Specifically to this PR, just one thing: any reason to not color the × of the same color of clickable links? It seems it would differentiate it enough, and contrast should always be ok as it's the same as text. More broadly... I know we are still working on this, but I want to make sure we don't ignore it: I think we need to be a better in terms of grid here. The alignments are really all over and it seems it would benefit from a better grid to put in earlier :) |
That's what I'm hoping @jsnmoon can do by using a regular link as discussed here. The only problem there would be ensuring solid contrast with the background on both our light and dark themes on the overlay, which could be an issue.
Agreed, but this is a side-effect of inheriting so many styles and markup from the theme itself. The grid is all broken in your screenshot, but it might look good on a different theme. Unfortunately there's no way to fully control that unless we use 100% custom markup and styles. By the way, the position of the close button was done purposefully so half of it is always placed outside the content; see screenshot on the OP. |
Sure, but if it's the same color as the link text...
I'm a bit perplexed. If we take for example the top area and make a full witdh piece, so the sidebar doesn't go as high up, then at least that alignment is preserved and would work regardless of the theme, no? What are our reference themes to make sure it works well on these? |
The link color is optimized for a single background color more often than not. Take Twenty Seventeen for example: the link color is black because it was only considered for its white background and that works nicely with our JPS “Light” theme. However, when the JPS “Dark” theme is applied, the cross is virtually invisible. See #14666 for a related issue and possible solution that doesn't require manual overrides.
Yep, there's more we can do on that front and we'll do it.
Our solution should ideally be universal as advertised. So with that in mind I'm personally testing changes on ~15 themes, including the latest Twenty * and some of the more popular ones on .org. But with JPS audience in mind, I'd say we're more likely to see it being used with custom themes. |
Your work made it super easy for me to bind the necessary functionality, thanks! I went ahead and pushed two commits: One for hooking up the close overlay function to SearchResults and another for changing the |
aee616f to
efbac64
Compare
|
@jsnmoon Thanks for hooking everything up! Works as expected, merging now. |
* Instant Search: add label and button to search box (#13875) * Add label and button to search box and convert to functional component * Correct lodash import * Instant Search: Ignore empty query values for filters (#13934) * Instant Search: Pay down technical debt (#13847) * Instant Search: Standardize class and ID prefixes (#13933) * Instant Search: Improve accessibility (#13884) * Turn statements into sentence fragments * Add appropriate landmark roles for elements * Set portaled widget as a search form * Use ordered list for search results * Instant Search: only show multiple image icon for posts with gallery (#13968) * Add testing instructions to README (#13969) * Instant search: add product result component (#13826) * [not verified] Add product search result component * [not verified] Refactor renderResult into component * [not verified] Convert SearchResult to stateless functional component * [not verified] Move comments to new shared component * [not verified] Move Tracks out to common SearchResult * [not verified] Request additional fields for product results * Correct field names and remove ratings for now * Basic styling of cards with images * Add price where available * Read result_format from the query string * Use ordered list * Style cleanup * Minor cleanup * Remove resultFormat from component state * SearchResults component cleanup * Standardise class names * Validate result format before using as CSS class * Address review nits * Instant Search: Restore caching to API requests (#13981) * Instant Search: add basic Photon support (#13998) * Add PhotonImage component * Bump default dimensions to 300x300 * Bump asset size limit to 100kb * Add layout CSS for product results (#14017) * Instant Search: Add error/offline handling for API (#14125) * Instant Search: move date into new component and use <time> element (#14133) * Instant Search: improve display of matching comments (#14132) * Instant Search: add label and button to search box (#13875) * Add label and button to search box and convert to functional component * Correct lodash import * Instant Search: Ignore empty query values for filters (#13934) * Instant Search: Pay down technical debt (#13847) * Instant Search: Standardize class and ID prefixes (#13933) * Instant Search: Improve accessibility (#13884) * Turn statements into sentence fragments * Add appropriate landmark roles for elements * Set portaled widget as a search form * Use ordered list for search results * Instant Search: only show multiple image icon for posts with gallery (#13968) * Add testing instructions to README (#13969) * Instant search: add product result component (#13826) * [not verified] Add product search result component * [not verified] Refactor renderResult into component * [not verified] Convert SearchResult to stateless functional component * [not verified] Move comments to new shared component * [not verified] Move Tracks out to common SearchResult * [not verified] Request additional fields for product results * Correct field names and remove ratings for now * Basic styling of cards with images * Add price where available * Read result_format from the query string * Use ordered list * Style cleanup * Minor cleanup * Remove resultFormat from component state * SearchResults component cleanup * Standardise class names * Validate result format before using as CSS class * Address review nits * Instant Search: Restore caching to API requests (#13981) * Instant Search: add basic Photon support (#13998) * Add PhotonImage component * Bump default dimensions to 300x300 * Bump asset size limit to 100kb * Add layout CSS for product results (#14017) * Instant Search: Add error/offline handling for API (#14125) * Instant Search: move date into new component and use <time> element (#14133) * Instant Search: improve display of matching comments (#14132) * Instant Search: default to query string in `getResults()` (#13995) * Instant Search: use default values for getting results to avoid duplication * getResults: default to empty object Co-Authored-By: Jason Moon <[email protected]> * Instant Search: add search form to main content area (#14142) * Split search form out of widget component so it can be reused in the main search area * Include search form in main content area * Move sort wrapper into component and improve class name * Give sort component a more sensible name * Keep search form in place when there are no results * Just return null when there isn't a query * Combine pagination conditionals into one clause Co-Authored-By: Jason Moon <[email protected]> * Drop SearchResultsEmpty component * Tidy pagination logic * Pass all props down to SearchForm * Instant Search: add filter icon toggle (#14176) * Add filter icon * Simple show/hide toggle * Make it an interactive element * Add aria-hidden to gridicon * Instant Search: Improve UX for offline network state (#14189) * Fix invisible space breaking date layout * Restore info Gridicon * Add warning notice component * Check offline state before using short term cache * Inject cache state variables into response data * Show “cached results” notice when the user is offline * Catch connectivity error and notify the user * Show correct number of results when offline * Hide load more button when offline * Wrap new copy in translation calls * Instant Search: try using an overlay (#14205) * Try the overlay (Hotel California edition) * Add button to close overlay * Always display search form attached to search results * Add a note about portaled search inputs * Use showResults instead of using showOverlay value * Add a large z-index and increase opacity * Simplify SearchApp, trigger overlay on input focus * Disable WordPress Search for Instant Search * Revert "Disable WordPress Search for Instant Search" This reverts commit 65b7dcb. * Add jetpack namespace to translation Co-Authored-By: Jason Moon <[email protected]> * Use the searchInputSelector Co-Authored-By: Jason Moon <[email protected]> * Add missing quote * Instant Search: setup preact-testing-library (#13950) * Add preact-testing-library * Rebase * Add instant-search dir to existing Jest config * First attempt at test * Tidying * Create 'yarn test-search' * Remove package-lock.json * Add jsx pragma * [not verified] * Enable test and added dependency docblocks * Remove rogue Slack package * Instant Search: Port bug fixes from #14247 * Add basic build process to README. * Instant Search: trigger overlay on submit (#14248) * Remove focus event listeners * Respond to submit rather than focus * Allow enter key to launch overlay * Reflect widget search input changes in query string * Close overlay with Esc key * Reflect query string change in search widget input * Make sure the sort options match * Try grabbing focus in getResults * Remove focus code * Remove grabFocus (no longer in use) * Handle overlay escape key with useEffect rather than converting to Component * Move closeOnEscapeKey out of render * Instant Search: Add sidebar widget area (#14283) * Fix linting violations by changing `date` invocations to `gmdate` * Add sidebar widget area * Add SearchSidebar component * Integrate SearchSidebar into SearchResults * Implement Overlay animation from design prototype * Instant Search: refactor search php for the different experiences (#14284) - refactor php to extract all instant search code - add customizer for the overlay - add running the search query on the backend to display filters when the page loads. * Instant Search: fix Esc key behaviour (#14312) * Instant Search: prevent Esc from opening overlay * Use isVisible rather than shouldShowOverlay * Instant Search: Add search filtering inside overlay (#14319) * Add SearchFilters above SearchSidebar * Instant Search: Add a button to clear applied filters (#14324) * Add function to clear filter query values * Fix class names for elements in SearchFilter * Add “Clear Filters” button * Instant search: introduce overlay from right (#14339) * Introduce overlay from right * Updating overlay offset values - Changes units from `vh` to `vw`. - Updates value from `200` to `100`, as [mentioned here](#14320 (comment)). Co-authored-by: Filipe Varela <[email protected]> * Use the posts_per_page setting to decide how many posts to retrieve (#14360) * Instant Search: Use widgets inside overlay for filtering (#14374) * Add search filter portaling inside overlay sidebar * Update readme with new testing instructions * Instant Search: update overlay styles (#14379) * Make search input as large as possible * Remove opinionated styles * Add more margin to the filter icon * Add screen reader text for the search box * Change order of date element * Change date position * Clean up styles * Update style for comments in search results * Fix name of CSS property * Make search result title class more specific Also reorders styles See: #14379 (comment) * Remove extra screen reader text See: #14379 (comment) * Instant Search: Fix taxonomy name compilation bug (#14408) * Instant Search: Fix date formatting issue for filters (#14409) * Instant Search: Integrate customizer options (#14427) * Integrate customizer options for search overlay * Fix infinite scroll functionality * Update spacing on offline notice (#14419) * Instant Search: add dark theme styles (#14429) * Update styles for base overlay * Update styles for search results * Fix filter toggle and integrate with widget area (#14451) * Instant Search: Improve search form detection (#14474) * Instant Search: Prevent body scroll with overlay open (#14478) * Instant Search: Move focus into overlay input (#14477) * Move focus to and from overlay * Use useRef and event listeners for focus shifting Co-authored-by: Chris R <[email protected]> * Instant Search: use taxonomy name rather than slug for filters (#14437) * Instant Search: use taxonomy name rather than slug * Fix display of category filters * Update buildFilterObject() * Fix filter formatting in Zerif Lite (#14493) * Instant Search: switch to use .slug_slash_name for displaying custom taxonomies, tags and categories (#14492) * Switch to use .slug_slash_name for taxonomies, tags and categories * Use slug in the query, and name for display * Instant Search: Hotfix body scrolling behavior * Instant Search: Apply customizer changes without page reload (#14504) * Instant Search : Update mobile structure (#14423) * Add cross gridicon * Replace close button label by a gridicon * Change position of close button * Update z-index stacking order Prevents sidebar to be in front of the close button * Reorder CSS properties * Add medium break point at 768px * Add mobile styles for filters popover * Change how transparency is set on the overlay * Update break-small to break-medium * Add styles for smaller close button on mobile devices * Add arrow element to popover * Remove styles that are out of place Given the markup has changed in #14477, these styles need to be applied elsewhere * Update search results styling * Add popover styles * Update filter icon margins * Show sidebar filters up to 768px See: #14423 (review) * Bring up the opacity on the arrow border * Reduce side padding on small screens * Move margin to label span instead of select element * Instant Search: Restore initial href upon closing overlay (#14518) * Restore initial href when closing overlay * Fix incorrect inline style removal * Instant Search: Restore focus to activeElement (#14522) * Search: Front end search filters open overlay (#14448) - Refactor filter display for front end - Remove rendering filters in the overlay - Front end filters open the overlay * Instant search: add "powered by Jetpack" message (#14519) * Show JetpackColophon when setting is activated * Translate text * Added logo and styles * Style tweaks * Link to jetpack.com/search * Add colophon to mobile filters * Margin tweak * Instant Search: Clear search and filter queries when necessary (#14533) * Clear search and filter queries if necessary * Improve initialHref restoration function * Create a separate handler for popstate events * Instant Search: Refine TrainTracks integration (#14587) * Instant Search: Fix broken dates in iOS Chrome (#14586) * Instant Search: Update list of widgets passed to JS client (#14596) * Only return widgets inside the overlay sidebar * Remove overlay sidebar membership check in JS * Instant Search: Escape wp_json_encode * Instant Search: Add missing translation calls * Update escaping from code review. * Instant Search: Fix unit tests * Instant Search: Fix ESLint errors * Instant Search: Add files to PHPCS whitelist * Instant Search: Add Jetpack Search gridicon (#14629) * Add Jetpack Search gridicon * Update search icon * Pass size variables to all SVG params * Increase icon size to 28px * Adjust padding around the icon Co-authored-by: Filipe Varela <[email protected]> * Instant Search: Hotfix customizer highlight color * Instant Search: Update TrainTracks to add session_id event property (#14655) * Ensures widgets included in the overlay are full width (#14670) * Prevents the load more button from being cut off in some themes (#14669) Adds margin bottom to the primary area of the overlay, which solves this problem but is also good practice to ensure search results are readable until the very last one. * Instant Search: remove date from search results (#14665) * Remove search result date component * Remove date from minimal search results * Remove styles associated with date * Add locale prefix to jetpack.com link. (#14637) * Instant Search: Address review feedback from master merge (#14659) * Address straightforward review feedback * Update transient cache name * Use add_query_arg * Improve user agent with WP/JP versions * Fix undefined index notices * Use a8c/color-studio for SCSS color variables * Hot fix for search css not building * Pass locale props to JetpackColophon on mobile (#14709) * Instant Search: update input box and icon styles (#14664) * Fix Gridicon's viewBox values We shouldn't be messing with the values in viewBox at all since all icons have a baseline of 24 x 24 px. While sizing changes, their set up should be consistent. Reported in: #14629 (comment) Thanks for catching this @jsnmoon ! * Revert search icon back to 24px * Update syling of main search box Complementary to #14661 * Remove magnifying glass logo options from the Customizer * Remove magnifying glass options from live reload * Stop passing unused showLogo option * Add generic search icon, reorder icons alphabetically * Rework markup on the search box - Adds Gridicon and input inside label. - Moves screen reader text to its own span. - Uses generic search icon. * Updates styling for the search box and its elements * [not verified] Remove magnifying glass from overlay options * Fix transition focus bug Co-authored-by: Jason Moon <[email protected]> * Instant Search: change visual on close button (#14680) * Change close button to a div * Update close button styling * Remove Close Button from the Customizer * Remove close button options from Customizer live reload * [not verified] Remove close button from overlay options * [not verified] Revert change of order class comment * Remove close button from overlay.jsx * Add close button to search-results.jsx * Change position for the close button * Change theme styling for the close button * Hook closeOverlay prop in SearchResults * Use anchor instead of div for close button Co-authored-by: Jason Moon <[email protected]> * Instant Search: Hide mobile filters after applying filters (#14691) * Handle case where locale is unavailable * Hide mobile filters upon filter selection * Hide popover upon clearing filters * Hide popover upon changing sort * Instant Search: Properly handle numerical searches (#14692) * Correctly handle numerical query values * Exclude Instant Search inputs from being selected * Instant Search: add more styling specificity to search input (#14661) * Ensure there's a cross to clear search on browsers that support it * Reduce font-size on results count text * Make close button behave similarly on different themes * Ensure there's a cross to clear search on browsers that support it * Reduce font-size on results count text * Make close button behave similarly on different themes * Ensures the clear button is displayed in the search box Props to @jsnmoon * Instant Search: use link to clear filters instead of button (#14744) * Use link for clear filters instead of a button * Update name in CSS * Instant Search: improve grid structure in overlay (#14745) * Add className to label * Ensure search box is always full-width * Improves alignment of the layout grid * Tweak close button position * Instant Search: updates behavior and styling of filtering options (#14711) Sorting buttons and "Filter" button drop down on mobile. Co-authored-by: Jason Moon <[email protected]> Co-authored-by: Greg Ichneumon Brown <[email protected]> * Remove unused showLogo property Co-authored-by: Chris R <[email protected]> Co-authored-by: Greg Ichneumon Brown <[email protected]> Co-authored-by: Filipe Varela <[email protected]> Co-authored-by: Sampath Jaini <[email protected]>




Addresses issue reported in #14616
Changes proposed in this Pull Request:
This PR originated from an issue reported in #14616 that mentioned the close button was placed behind the system scrollbar. This happens because we're applying
overflow-y: hiddenon thebodyand adding overflow on the overlay itself.The design team weighed in and the solution here is to get rid of the
background-coloron the close button, and to simply have a floating×. As a nice side-effect, this should give more focus to the content itself since the close button, depending on the color applied, could demand too much attention in some cases.Here's the breakdown of all changes:
a.Light theme:

Dark theme:

Placement reference on desktop:

Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
Proposed changelog entry for your changes: