Skip to content
This repository has been archived by the owner. It is now read-only.

feat(mc): Implement search suggestions by reusing contentSearchUI #2611

Merged
merged 1 commit into from May 25, 2017

Conversation

@Mardak
Copy link
Member

@Mardak Mardak commented May 18, 2017

Fix #2517. I was looking into implementing suggestions, and noticed contentSearchUI has all sorts of fancy/featureful/accessible/etc code. Any particular reason we shouldn't reuse all that logic that powers the existing newtab and home pages? It's not the UI as designed for activity-stream and just plain html as opposed to React. ni?@k88hudson

Here's a webm/gif video of a search in activity-stream that can be hooked up with just a few lines adding the script, css, and calling the constructor:

https://people-mozilla.org/~elee/activity-stream/activity-stream.search.webm
activity-stream.search.gif

If you're not familiar with the keyboard behavior, you can press down to select items (form history as well as search suggestions) and also press alt-down to select a one-off search.

Updated PR with UI tweaks and tests and other cleanup:
image

@coveralls
Copy link

@coveralls coveralls commented May 18, 2017

Coverage Status

Coverage remained the same at 88.598% when pulling eaca08c on Mardak:gh2517-search into 72f12c6 on mozilla:master.

// Trigger initialization of ContentSearch in case it hasn't happened yet
dispatchEvent(new CustomEvent("ContentSearchClient", {detail: {}}));
componentDidMount() {
let searchText = document.getElementById("search-input");

This comment has been minimized.

@k88hudson

k88hudson May 18, 2017
Member

I would use a ref for this instead of an id

@k88hudson
Copy link
Member

@k88hudson k88hudson commented May 18, 2017

This is great! I am all for avoiding duplication of code 👍

I think the only thing needed here is a bit of polish on the edge where the suggestions touch the bottom of the input (it looks a little rough at the moment)

@Mardak Mardak force-pushed the Mardak:gh2517-search branch from eaca08c to 177a9d6 May 19, 2017
@Mardak Mardak changed the title WIP Reuse contentSearchUI instead of directly calling ContentSearch feat(mc): Implement search suggestions by reusing contentSearchUI May 19, 2017
@coveralls
Copy link

@coveralls coveralls commented May 19, 2017

Coverage Status

Coverage remained the same at 88.598% when pulling 177a9d6 on Mardak:gh2517-search into a9ca91b on mozilla:master.

Copy link
Member

@k88hudson k88hudson left a comment

Looks good to me – the only change is that the square corner should only be applied when aria-expanded="true"

@@ -184,7 +184,6 @@
input {
@include search-input;
border-top-left-radius: $search-border-radius;
border-bottom-left-radius: $search-border-radius;

This comment has been minimized.

@k88hudson

k88hudson May 24, 2017
Member

This should be rounded, and only 0 when suggestions are visible

This comment has been minimized.

@Mardak

Mardak May 24, 2017
Author Member

Oh indeed! Nice catch.

This comment has been minimized.

@Mardak

Mardak May 25, 2017
Author Member

I changed this to use the 4-in-1 border-radius to avoid issues with accidental ltr partial border styles affecting rtl partial border styles. In this case it would have been okay as the ltr "expanded" bottom-left being 0 happens to match the rtl non-"expanded" bottom-left already being 0.

@@ -184,7 +184,6 @@
input {
@include search-input;
border-top-left-radius: $search-border-radius;
border-bottom-left-radius: $search-border-radius;
padding-inline-start: 35px;

&:focus + button {

This comment has been minimized.

@Mardak

Mardak May 25, 2017
Author Member

Ah doh. I thought I didn't need to change button to .search-button here as it's effectively scoped to just the actual search button, but CSS specificity calculations with the element caused styling to get messed up relative to the lower specificity of the class selector.

@Mardak Mardak force-pushed the Mardak:gh2517-search branch from 177a9d6 to 019655d May 25, 2017
@coveralls
Copy link

@coveralls coveralls commented May 25, 2017

Coverage Status

Coverage remained the same at 88.064% when pulling 019655d on Mardak:gh2517-search into c762a23 on mozilla:master.

@Mardak Mardak merged commit 8ab1982 into mozilla:master May 25, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 88.064%
Details
@Mardak Mardak deleted the Mardak:gh2517-search branch May 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants