-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Hierarchy expansion on search #1598
Conversation
…matched parts of the nodes
…-on-search Conflicts: lib/ui/src/modules/ui/components/left_panel/stories_tree/index.js lib/ui/src/modules/ui/components/left_panel/stories_tree/tree_decorators.js
# Conflicts: # lib/ui/src/modules/ui/components/left_panel/stories_tree/tree_decorators.js # lib/ui/src/modules/ui/components/left_panel/stories_tree/tree_style.js
dude you're on 🔥 !! looking incredible. |
@@ -1,6 +1,6 @@ | |||
import PropTypes from 'prop-types'; | |||
import React from 'react'; | |||
import debounce from 'lodash.debounce'; | |||
import { debounce } from 'lodash'; |
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.
What was wrong with the method package?
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 didn't manage to mock it...
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 it can be mocked just as identity function: fn => fn
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.
Yeah, that what I did.. But problem looks like in a way of the import.. In the transpiled version
of the import ... from lodash.debounce
I am getting a reference to the debounce
function. And in transpiled version of named import - the reference is to the lodash
object, in this case I managed to replace its method. 🤕
Codecov Report
@@ Coverage Diff @@
## master #1598 +/- ##
==========================================
+ Coverage 21.05% 21.35% +0.29%
==========================================
Files 244 244
Lines 5310 5376 +66
Branches 652 660 +8
==========================================
+ Hits 1118 1148 +30
- Misses 3690 3726 +36
Partials 502 502
Continue to review full report at Codecov.
|
🔥 |
return name; | ||
} | ||
|
||
const filterRegex = new RegExp(`(${storyFilter})`, 'i'); |
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.
Looks like this will break with special characters, plus it's not how the stories are actually filtered. I'd suggest to use Fuse.js with { includeMatches: true }
in libs/filters.js
and store the matches information in some dedicated field on the filtered stories
Chatted with @Hypnosphi in slack. Our current Already mentioned Fuse.js lib is very promising and can help us improve both filtering and highlighting features (built-in matches indices in the result). However they have a PR that is vital for us. So we can make a fork (like with the react-treabeard). Other alternative might be this small lib - https://github.com/mattyork/fuzzy/blob/master/lib/fuzzy.js. In other words I think this change is bigger than just PR to master.. What do you guys think ? |
We can make a fork and send a new PR with tests =)
How exactly would you use it for highlighting? |
@igor-dv I think the current behavior is perfect for most real-world component libraries, which never grow particularly big/complex. You're always welcome to make it better, but if it was me I would just ship it as is. |
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.
LATM! (A = awesome!)
It looks really awesome to me, too, but those two issues should be addressed (at least the first one). |
# Conflicts: # lib/ui/src/modules/ui/components/left_panel/index.js
I've fixed the special characters issue. @shilman regarding the highlighting, here is an example when it breaks.. I think if there are no strong objections we can merge this one (after I'll add few tests, probably tomorrow) And add the Fuse.js as a separate PR (and maybe as part of the next release). |
Great! The first issue is gone, the second one can be solved in a scope of another PR |
What I did
How to test
run
cra-kitchen-sink
and perform filterTBD
Add tests !!