Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Adding navigation button to Search Input. - #2463

Merged
jasonLaster merged 4 commits into
firefox-devtools:masterfrom
wldcordeiro:search-nav-buttons
Apr 6, 2017
Merged

Adding navigation button to Search Input.#2463
jasonLaster merged 4 commits into
firefox-devtools:masterfrom
wldcordeiro:search-nav-buttons

Conversation

@wldcordeiro

@wldcordeiro wldcordeiro commented Mar 27, 2017

Copy link
Copy Markdown
Contributor

Associated Issue: #2387

The previous PR was made against master and github got confused and closed it when I rebased. I'm reopening on behalf of @nadavoran with some tweaks and fixes to pass CI.

Summary of Changes

  • Add the up/down arrow navigation to the SearchInput and use in file search (@nadavoran's original work)
  • Tweak the original PR to pass lint/CI, add the navigation to project search

Test Plan

  • Command-P opens the project search
  • type a search with multiple results, click the next/prev arrows to traverse
  • type a search with one result and see no arrows
  • try the same with file search (both with symbol searching and code searching.)

Screenshots/Videos

screenshot_20170327_021426
screenshot_20170327_021440
search-nav-demo

Comment thread src/components/shared/SearchInput.js Outdated
Svg("arrow-up", {
className: classnames("nav-btn", "prev"),
onClick: handlePrev,
title: "Previous Result",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could put these in L10N.

@codecov

codecov Bot commented Mar 27, 2017

Copy link
Copy Markdown

Codecov Report

Merging #2463 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2463   +/-   ##
=======================================
  Coverage   54.07%   54.07%           
=======================================
  Files          51       51           
  Lines        1986     1986           
  Branches      398      398           
=======================================
  Hits         1074     1074           
  Misses        912      912

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1e196f...5e40a3b. Read the comment docs.

@jasonLaster jasonLaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up.

One highlevel point, I think next/prev makes more sense for text search and less sense for project and function search which are list based. The rationale is that scrolling through a list is very efficient, whereas jumping to the next item in a file can be trickier.

}
this.setState({ selectedResultIndex: nextResultIndex });
this.onSelectResultItem(searchResults[nextResultIndex]);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - I'm a bit confused by this logic.

It looks very similar to what we're doing in search search to determine the next index. Is there an easy way we can unify it?

Comment thread src/components/Editor/SearchBar.js Outdated
nextResultIndex = 0;
}
this.setState({ selectedResultIndex: nextResultIndex });
this.onSelectResultItem(searchResults[nextResultIndex]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it can be shared too...

Comment thread src/components/shared/SearchInput.js Outdated
title: "Previous Result",
})
);
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchInput could be a good component to snapshot test:

https://facebook.github.io/jest/docs/snapshot-testing.html#content

className: classnames("nav-btn", "next"),
onClick: handleNext,
title: "Next Result",
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's our preference with wrapping - next at the end and previous at 0?

@jasonLaster

Copy link
Copy Markdown
Contributor

This looks much better, I'll review soon!

@jasonLaster

jasonLaster commented Apr 4, 2017

Copy link
Copy Markdown
Contributor

Rebased and it works great.

Here's a GIF to see how great it is:

@jasonLaster
jasonLaster force-pushed the search-nav-buttons branch 2 times, most recently from ee36e2f to fd94386 Compare April 4, 2017 20:40

@jasonLaster jasonLaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some small tweaks, but lets land this and we can always polish later!

@wldcordeiro

Copy link
Copy Markdown
Contributor Author

Working on a rebase/polish commit now. Hopefully will push today (vacation is slowing me down 😆)

@jasonLaster

jasonLaster commented Apr 5, 2017 via email

Copy link
Copy Markdown
Contributor

@jasonLaster jasonLaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looking better

Comment thread src/components/Editor/SearchBar.js Outdated
onChange: this.onChange,
onKeyUp: this.onKeyUp,
onKeyDown: this.onKeyDown,
handleNext: e =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, not sure if we need the ternary. if we're not rendering the buttons will these be used?

}

renderNav() {
const { count, handleNext, handlePrev } = this.props;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets put the feature flag here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, forgot to feature flag it. 😆

@nadavoran

Copy link
Copy Markdown

Wow that looks great, thanks for adding this and all your work to make it so nice

@jasonLaster
jasonLaster merged commit 896c1fd into firefox-devtools:master Apr 6, 2017
@jasonLaster

Copy link
Copy Markdown
Contributor

Thanks @nadavoran for getting this started!
Thanks @wldcordeiro!

@wldcordeiro
wldcordeiro deleted the search-nav-buttons branch April 6, 2017 23:31
DanUgelow pushed a commit to DanUgelow/debugger.html that referenced this pull request May 4, 2017
* Adding navigation button to Search Input. re firefox-devtools#2387

* Only show search navigation for file text search.

* Reduce some redundancy in SearchBar for traversing results.

* Feature flag the search navigation buttons and remove redundant ternary.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants