-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Search in Doc Explorer #80
Conversation
7eed13a
to
f62ce22
Compare
@@ -45,8 +45,8 @@ export class DocExplorer extends React.Component { | |||
// Public API | |||
showDoc(typeOrField) { | |||
var navStack = this.state.navStack; | |||
var isCurrentlyShown = | |||
navStack.length > 0 && navStack[navStack.length - 1] === typeOrField; | |||
var isCurrentlyShown = navStack.length > 0 && |
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.
This is an unnecessary change - reverting.
5f6105c
to
59002c9
Compare
this.state = { navStack: [] }; | ||
this.state = { | ||
navStack: [], | ||
searchValue: null |
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 think searchValue should probably be part of the nav stack rather than it's own thing, so that you can search, click on something, click back and be where you were before.
This could be done in a separate PR though, since it's a bit beyond what's happening here
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.
Exactly; I would like the search action to be a part of navStack - something like:
navStack = [
testType: { ... },
graphiql_search: { value: ... },
];
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.
A related note about navStack for the future: it would be cool if scroll position were also maintained as part of the back stack. Today if you click from a long scrolling view to another long scrolling view your scroll position is maintained when it should probably be reset to "0", but then when going "back" the original scroll position should be restored. It's a fairly small detail, but it will help make navigating larger schema easier on the mind.
This is awesome! There are some comments inline, but this is pretty close to landing as an initial version of search. |
59002c9
to
0a92996
Compare
Responded to comments:
|
@@ -103,12 +114,21 @@ export class DocExplorer extends React.Component { | |||
field={typeOrField} | |||
onClickType={this._onClickTypeOrField} | |||
/>; | |||
} else if (this.state.searchValue) { | |||
title = 'Search Results'; | |||
content = <SearchDoc |
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: use the same styling here as in the else block below, line break and indent.
This looks great. I have a few other comments in there. One overarching minor thing: it's nice to use Once you've covered all the comments and updated it, merge away! |
let matches = field.args.filter(arg => { | ||
return arg.name.indexOf(searchValue) !== -1; | ||
}); | ||
matchedFields.push( |
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.
This will allow search results to match arguments/render fields every time. Fixed:
if (matches.length > 0) {
0a92996
to
f4b97f3
Compare
Thanks @leebyron! |
…ransform-es2015-spread-6.22.0 Update babel-plugin-transform-es2015-spread to version 6.22.0 🚀
Search functionality in Documentation Explorer.
It's pretty basic with searching/getting results/clicking links - I'll incrementally add in more details in upcoming PRs.
EDIT: added no-search-result case and minimum character length