# Filters

![](http://img.badgesize.io/procore/particles/master/filters/index.js)
![](http://img.badgesize.io/procore/particles/master/filters/index.js?compression=gzip)
![](https://badge.fury.io/js/%40particles%2Ffilters.svg)

A dynamically populated lazy loading filter component.

# Example

![filters](https://user-images.githubusercontent.com/8366399/34239180-79523ed0-e5ba-11e7-9bac-f184d043eda3.gif)

# Change Log

##### 14.2.7

- Fixed bug with location filter where some locations would erroneously appear selected if another location that started with the same characters was selected and "Include Sublocations" was also selected

##### 14.2.6

- Fixes masking issues for locales with different separators.

##### 14.2.5

- Remove fsevants dependency introduced in 14.2.2 that causes CI failure.

##### 14.2.4

Localize filter calendar

- Add support for newer locales like fr-FR, de-DE, zh-SG etc.
- Add support for the correct start day of the week.
- Fix masking bug with locales such as ko, jp-JP etc.
  Note: Skipped 14.2.3 since we had to un-publish that version.

##### 14.2.2

- Added data-qa tags to Filters for automation testing

##### 14.2.1

- Fix a bug where selecting a location without `Include Sublocation`, then selecting `Include Sublocation`, and then the original location cannot be unselected

##### 14.2.0

- Fix a bug where selected filters are active in disabled state
- Update styles on filter options to match them with core-labs components.
- Fix a bug where word wrap breaks the word in filter options.

##### 14.1.0

- Added data-qa tags for automation testing

##### 14.0.0

- `toUtc` updated to only pass back the string without timezone as locale is not properly setup for moment usage. passes back just the `YYYY-MM-DD` string instead now.

##### 13.0.7

- Fix incorrect locale designators
- Update to use Procore's locale specific date formats where they differ from Moment's standard

##### 13.0.6

- Fix a bug where when a filter bar had multiple `FilterCheckbox`s, only the first filter would save filters when clicking outside of the dropdown.

##### 13.0.5

- `FilterCheckbox` components' selections stay up to date when the `Filters` component's selections get changed.

##### 13.0.4

- Update index

##### 13.0.3

- Internationalize `Include Sublocations` option for locations filter

##### 13.0.2

- declare `core-react` as a `peerDependency` as well as a `devDependency`

##### 13.0.1

- use autoHeight on react-virtualizer/List-

##### 13.0.0

- Options now wrap. Introducing CellMeasurer for measuring heights
- `react-virtualizer` mocked for testing

##### 12.0.0

- `onFetch` function no longer returns a promise.
- Removes `onFetchFail` prop.

##### 11.0.0

- Core-react is now a required external dependency.

##### 10.1.0

- Adds onRemoveFilter prop.

##### 10.0.0

- Now `onFetch` function takes a function that returns a promise.
- Implemented `onFetchFail`. Signature: `onFetch(filter, error)`.

##### 9.4.0

- Upgrade `core-react` version to v7.

##### 9.3.1

- Adjusts styles to better match Core specs

##### 9.3.0

- Adds category checkbox filter type

##### 9.2.0

- Adds Pre-menu calendar filter type

##### 9.1.0

- Virtualizes location filter to improve performance time of initial render.
- Adds loading state for location filter select all when there is > 1000 locations. Select all starts to lag over this amount.

#### 9.0.2

- Removes assigned font-family from the calendar date-picker filter.

##### 9.0.1

- Fixed moment locale by explicitly call `moment.locale` issue.

##### 9.0.0

- _Breaking_ Requires use of `I18n.Provider` from [core-react](https://procore.github.io/core/latest/#/react/introduction/overview) to provide _I18n_ translations object via context. This was done to prevent the need for the developer to provide individual translations as props to `Filters`.

##### 8.0.1

- Fixes calendar width in IE 11 and Edge

##### 8.0.0

- _Breaking_ This is a breaking behavior change for location filters.
- _Breaking_ Location filter now only returns parent location ids when include sublocations is checked.
- _Breaking_ `onSave` prop returns `options` as a second argument which includes `isIncludeSublocations`.
- Checking `include sublocations` now adds a disabled checked state to sublocations of the selected root
- Moved filter calendar saving logic from Filters component to FilterCalendar component.

##### 7.2.0

- Adds support for multiple calendar filters

##### 7.1.0

- Refactor Filters to allow passing custom filter components that implements a common interface that is either checkbox, location, or calendar
- Updated sandbox to include an demo on implementing a custom filter

##### 7.0.3

- Fixes FilterCalendar to accept stylesheets as prop

##### 7.0.2

- Upgrades react and react-dom to 16.2.0, enzyme-adapter-react to 16

##### 7.0.1

- Remove max-height 100% from .tokenBodyScroll in favor of .tokenBodyCheckbox max-height in px (to support virtualized FilterCheckbox in IE 11)
- Remove min-height from .tokenBodyScroll in favor of adding vertical padding to .emptyMessage

##### 7.0.0

- _Breaking_ For FilterCheckbox, specify filterCheckboxRowHeight as a prop if you changed the default row height value in your CSS
- _Breaking_ Requires React 15 or higher
- Virtualizes FilterCheckbox to improve performance times of initial render, select row, select all, and deselect all

##### 6.7.6

- Removes `font-family: Lato`, allows cascade of font

##### 6.7.5

- `.tokenBody` `overflow-y: auto` to fix IE 11 no scrolling bug

##### 6.7.3, 6.7.4

- Minor UX updates
- Newly added filters no longer trigger save on cleanup if empty

##### 6.7.2

- Set `flex-shrink: 0` on token's clear button and caret

##### 6.7.1

- Improving "select results" behavior to only affect visible boxes

##### 6.7.0

- "Locations" type filter added
- Loading spinner style updates

##### 6.6.1

- 250px checkbox dropdown width
- Default cursor on checkbox rows

##### 6.6.0

- Adding "select current" functionality
- Indeterminate checkbox state if "some selected"

##### 6.5.3

- Checkbox UX update

##### 6.5.2

- Disabled cursor when disabled
- Hover select all
- Checkbox UX update

##### 6.5.1

- UX updates.

##### 6.5.0

- Adding `disabled` prop which disables available filter dropdown

##### 6.4.1

- Fixing calendar filter input onFocus and onBlur

##### 6.4.0

- Adds tests for the calendar filter

##### 6.3.0

- Removes filters calendar isRange from savedFilters

##### 6.2.0

- Up arrow, down arrow, enter, esc, tab key listeners added
- Clear all removed
- Select all is now a checkbox

##### 6.1.2

- Sometimes 2 clicks are needed to blur the checkbox dropwdown, setting ignoreBlur to false after a millisecond prevents this.

##### 6.1.1

- Fixes i18n bug for the calendar filter

##### 6.1.0

- Adds the calendar filter
- Fixes CSS bugs

##### 6.0.1

- Built with all the latest styles
- Fixed up the Clear All default stylings

### 6.0.0

- _Breaking_ UI/UX overhaul
- Preprod unit test runner added
- Changed `DropdownCheckboxes` and `DropdownPlain` to `FilterCheckboxes` and `FilterAvailable`
- Removed Font Awesome in favor of inline SVG
- Removed legacy key listener code
- Standardized dropdown/active/inactive token styles into just `Tokens.scss`

### 5.0.0

- _Breaking_ Using pseudolocalization for i18n handling
- Lots more unit tests added

### 4.0.0

- _Breaking_ Filters no longer focus when you attempt to remove filter. Html and classnames were added/rearranged to `<DropdownCheckboxes/>`.

##### 3.2.2

- Add unit tests, CSS module mocking, and code coverage reporting.

##### 3.2.1

- Fixes a bug when there are savedFilters and the focusedDropdown and focusedDropdownFilters props are used

##### 3.2.0

- Adds focusedDropdown and focusedDropdownFilters props

##### 3.1.3

- Style scoping fix

##### 3.1.1, 3.1.2

- Fixing blur/submit bug in items body scroll

##### 3.1.0

- Analytics added

##### 3.0.4

- Updating webpack to support hosting from `0.0.0.0`

##### 3.0.3

- Restoring scrolling on filter body

##### 3.0.2

- A console warning appeared!

##### 3.0.1

- Expanding and populating when new filter added

### 3.0.0

- Removing URLs and remote fetching in favor of callbacks
- Removing address bar updating
- Using `tabindex` method for focus and blur

##### 2.6.2

- Fixed a bug where adding any new filters caused the filters to hang and never submit

##### 2.6.1

- Fixes a bug where it wouldn't update if updating the same filter

##### 2.6.0

- Loading of filter data deferred to clicking into them
- UX change: single selection back to looking like <Filter> (<count>)

##### 2.5.1

- Added esc key functionality
- Fixed arrow/enter bugs

##### 2.5.0

- Added support for arrow and enter key navigation/selection

##### 2.4.4

- Fixing saved filters if null array entry

##### 2.4.3

- Fixing saved filters if null entry

##### 2.4.2

- Updating package.json to Particles URL

##### 2.4.1

- Changed styling to generic colors, etc., fix prop-types deprecation warning

##### 2.4.0

- Will not call the external population function if nothing has changed

##### 2.3.2

- Added in internationalization placeholders for sandbox

##### 2.3.1

- When a filter selection has no `options` associated with it, the typeahead search bar is not available

##### 2.3.0

- When only one item is selected, it is displayed in the dropdown title token for better visibility

##### 2.2.6

- Added internationalization for placeholders
- The CSS file was alphabetized, and unnecessary overrides were removed
- Many micro style tweaks were made
- The dropdown body is now responsive with a min- and max-width
- The sandbox file has "more realistic" data now
- The typeahead search bar in the dropdown body now has a placeholder value
- Deleted unnecessary CSS files

##### 2.2.5

- Added backwards compatibility for saved filters that come back as arrays rather than objects

##### 2.2.4

- Removing reset.scss

##### 2.2.2, 2.2.3

- Small style fixes

##### 2.2.1

- Autofocus

##### 2.2.0

- Adding `filterOptions` function

##### 2.1.12

- Restored search functionality after clear.

##### 2.1.11

- Added graceful handling if no PATCH endpoint provided

##### 2.1.10

- If empty, DELETE not PATCH.

##### 2.1.9

- Persisting text search even if no results

##### 2.1.7, 2.1.8

- Text wrapping update
- Removing default hover and rotate on arrow

##### 2.1.6

- Fixed border handling
- Fixed truncation for long filter names
- Added padding so count doesn't bump against caret

##### 2.1.4, 2.1.5

- Fixing wrapping
- Changing filter width to responsive, not fixed

##### 2.1.3

- Removing sans-serif default on star selector

##### 2.1.2

- Fixed select all to respect search

##### 2.1.1

- Fixed restoring checkboxes regardless of data type

##### 2.1.0

- Fixed focus/click on inline search
- Styling updates
- Resetting "hidden" state during population
- Improved empty state handling

##### 2.0.1 - 2.0.5

- Adding Lerna publishing management
- Splitting out dev dependencies

##### 2.0.0

- Removed Immutable and Redux deps, now 90% smaller (770kb -> 66kb)
- Various styling upgrades for default component parity

##### 1.1.7

- Implemented prod builds

##### 1.1.6

- Removing unnecessary dependencies

##### 1.1.5

- Implemented Webpack 2.2.1

##### 1.1.4

- ENV variable support added

##### 1.1.3

- Ball In Court filter added

##### 1.1.2

- _Experimental; no significant changes_

##### 1.1.1

- Moving I18N from view to reducer

##### 1.1.0

- Callback functionality for use after initialization

##### 1.0.4

- Linting

##### 1.0.3

- Return to page 1 after filter update

##### 1.0.2

- Minor padding update

##### 1.0.1

- Centering checkboxes on multiline items
- Removing available filters if all added
- Updated count after selecting all

##### 1.0.0

- Initial commit
