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

General purpose search form component #2184

Closed
8 tasks done
chillu opened this issue Jun 11, 2018 · 10 comments
Closed
8 tasks done

General purpose search form component #2184

chillu opened this issue Jun 11, 2018 · 10 comments

Comments

@chillu
Copy link
Member

chillu commented Jun 11, 2018

Parent story: #1777

Acceptance Criteria

  • I can type in a search term
  • There's a configurable placeholder
  • I can clear my search term input (both in collapsed and expanded view)
  • I can toggle a view with more advanced search inputs
  • The advanced search inputs are configurable via a form schema
  • There are event hooks for triggering a search and clearing search results

Notes

Tasks

  • Set up component
  • Define reducer, state, actions
  • Update usage doc
  • Update Pattern lib
  • Write unit test
  • Update AssetAdmin to use the new search component instead (technically not part of the card, but it gives me something to test the component against and it won't be very long).

Pull requests

Related PRs

@maxime-rainville
Copy link
Contributor

Doesn't https://github.com/silverstripe/silverstripe-asset-admin/blob/1/client/src/components/Search/Search.js already a cover lot of the points in the acceptance critera?

I'm thinking I might be better moving it under admin and working from there.

@maxime-rainville
Copy link
Contributor

maxime-rainville commented Jul 5, 2018

The asset admin search components looks like this right now:

<Search
    onSearch={this.handleDoSearch}
    id="AssetSearchForm"
    searchFormSchemaUrl={searchFormSchemaUrl}
    filters={filters}
    formData={{}}
    />

filters receives GET URL param.
formData is populated from the redux state.
searchFormSchemaUrl is mandatory and allows a form schema to be passed.
AssetAdmin give it a folderId props which it doesn't do anything with.

I would tweak things this way.

<Search
    onSearch={this.handleDoSearch}
    onClear={this.clear}
    onShowFilters={this.showFilter}
    onHideFilters={this.showFilter}
    onShow={this.showSearch}
    onHide={this.hideSearch}

    show={true}
    hiddeable={false}
    showFilters={true}
    toggable={true}
    placeholder={searchTerm}
    id="RandomSearchForm"
    formSchemaUrl={searchFormSchemaUrl}
    filters={filters}
    formData={{}}
    />
  • placeholder is optional and will default to Search ...
  • toggable is true and show is false, a search button will be displayed without a search box. Clicking the search button will fire onShow.
  • toggable is true and show is true, a search box will be displayed with an X allowing the user the hide the search box. Clicking the X will fire onHide.
  • toggable is false and show is false, nothing will show. Some other component will have to open the search.
  • toggable is false and show is true, a search box will be displayed with an X allowing the user the hide the search box. Clicking the X will fire onHide.
    formSchemaUrl will be optional. If not set no advance filters will be available.
  • if hiddeable is false, the X mark will never show.

Edit

On second thought, I'll merge hiddeable and toggable into a displayBehavior that can be set to blank, hiddeable or toggable.

@maxime-rainville
Copy link
Contributor

I'm almost done with the basic set up of the component and the styling. There's a few question to clear up:

  • The current File Search component has an Advanced label when you hover over the drop down icon. That would clash with the clear/enter label, so I presume we need ditch this label.
  • There's a clear label that appears in some of the mock up, where the
    image sometimes appear. It's not immediately apparent to me when I should display enter and when I should display clear.

@maxime-rainville
Copy link
Contributor

Yeah finally got it over line.

Here's what it looks like. https://youtu.be/xNFkyLOgrzg

@robbieaverill
Copy link
Contributor

Looks awesome! Does the content area need a loading indicator to prevent the search button from rendering half way off the container? 😛

@maxime-rainville
Copy link
Contributor

maxime-rainville commented Jul 26, 2018

I've made some adjustments based on @clarkepaul's feedback: https://youtu.be/eAyTQYW-kXM

  • The bottom shadow will now display over the file side panel.
  • The Advanced fitler collapsable will now line up with the drop down button.
  • There's now a clear button showed directly in the search box where the [enter] would be shown as per the mock ups.

Getting the switch between the [enter] hint and clear button ended up being a bit of a mission, because I had to track if the search form was dirty and make sure it got reset to pristine on search.

The enter hint will show if the search box has the focus and is dirty.

The clear button will show if there's data to clear and if the enter hint is not showing.

edit
I'm not quite done. I still need to write some unit test for the new logic and fix linting.

@chillu
Copy link
Member Author

chillu commented Jul 26, 2018

Looks great, those Youtube previews are super helpful for low friction review. Great to see the pattern library being actively used as well

@clarkepaul
Copy link
Contributor

Functionality is working great :), do we have control over how the search suggested results appears?

@maxime-rainville
Copy link
Contributor

The suggested results you see in the vid is just the browser's native auto-suggest features. It remembers values you posted in the form previously and will offer them to you again.

We could use autocomplete=off on the input field and provide our own auto suggest feature, but that would probably need to be another card.

@maxime-rainville
Copy link
Contributor

@lukereative and I had a catch up with @newleeland today. That should be be last changes to this guy ... fingers crossed. Here's what's been changed

  • Got rid of the blue glow and blue border on focus.
  • Only display the shadow when the Search input box has the focus or when the advanced filters are open.
  • The clear button in the search box will now focus on the search box after click.
  • The clear button in the advanced filters form will now focus on the first field after click.

https://youtu.be/YEhsHme3pyk

@chillu chillu closed this as completed Aug 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants