Skip to content
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

Merged
merged 13 commits into from
Aug 6, 2017
Merged

Conversation

igor-dv
Copy link
Member

@igor-dv igor-dv commented Aug 4, 2017

What I did

  1. Expand all hierarchy when in a filter mode
  2. Highlight found patterns
  3. Added debouncing to the filter

filter-expand-highlight

How to test

run cra-kitchen-sink and perform filter

TBD

Add tests !!

…-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
@shilman
Copy link
Member

shilman commented Aug 4, 2017

dude you're on 🔥 !! looking incredible.

@Hypnosphi Hypnosphi self-requested a review August 4, 2017 20:34
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import debounce from 'lodash.debounce';
import { debounce } from 'lodash';
Copy link
Member

@Hypnosphi Hypnosphi Aug 4, 2017

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?

Copy link
Member Author

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...

Copy link
Member

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

Copy link
Member Author

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
Copy link

codecov bot commented Aug 4, 2017

Codecov Report

Merging #1598 into master will increase coverage by 0.29%.
The diff coverage is 65.71%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...i/components/left_panel/stories_tree/tree_style.js 25% <ø> (ø) ⬆️
...b/ui/src/modules/ui/components/left_panel/index.js 100% <ø> (ø) ⬆️
...rc/modules/ui/components/left_panel/text_filter.js 34.24% <42.85%> (+0.91%) ⬆️
...ponents/left_panel/stories_tree/tree_decorators.js 32.98% <69.56%> (-0.35%) ⬇️
...les/ui/components/left_panel/stories_tree/index.js 98.52% <94.73%> (-1.48%) ⬇️
.../src/manager/containers/CommentsPanel/dataStore.js 34.78% <0%> (ø) ⬆️
addons/notes/src/react.js 0% <0%> (ø) ⬆️
lib/ui/src/modules/shortcuts/actions/shortcuts.js 6.25% <0%> (ø) ⬆️
... and 24 more

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 38ff4cb...24a4140. Read the comment docs.

@ndelangen
Copy link
Member

🔥

return name;
}

const filterRegex = new RegExp(`(${storyFilter})`, 'i');
Copy link
Member

@Hypnosphi Hypnosphi Aug 5, 2017

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

@igor-dv
Copy link
Member Author

igor-dv commented Aug 5, 2017

Chatted with @Hypnosphi in slack.

Our current fuzzysearch lib is a bit limiting, since the only result it gives is whether the string matches to the query.

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.
It has no built in matches feature, but can be easily used as a source of truth for both - filtering and highlighting.

In other words I think this change is bigger than just PR to master..

What do you guys think ?

@Hypnosphi
Copy link
Member

However they have a PR that is vital for us. So we can make a fork (like with the react-treabeard).

We can make a fork and send a new PR with tests =)

It has no built in matches feature, but can be easily used as a source of truth for both - filtering and highlighting.

How exactly would you use it for highlighting?

@shilman
Copy link
Member

shilman commented Aug 5, 2017

@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.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LATM! (A = awesome!)

@Hypnosphi
Copy link
Member

Hypnosphi commented Aug 5, 2017

@shilman

  1. Please type \ in the filter and look into console
  2. Try to skip a letter in a search request. Stories are filtered, but not highlighted. What does it have to do with library size?

It looks really awesome to me, too, but those two issues should be addressed (at least the first one).

@igor-dv
Copy link
Member Author

igor-dv commented Aug 5, 2017

I've fixed the special characters issue.

@shilman regarding the highlighting, here is an example when it breaks..

image

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).

@Hypnosphi
Copy link
Member

Great! The first issue is gone, the second one can be solved in a scope of another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants