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

Refactor StaticFilters #50

Merged
merged 15 commits into from
Nov 8, 2021
Merged

Refactor StaticFilters #50

merged 15 commits into from
Nov 8, 2021

Conversation

yen-tt
Copy link
Contributor

@yen-tt yen-tt commented Nov 2, 2021

Refactor StaticFilters and update AppliedFilters to follow the new public interface from answers-headless.

  • update StaticFilters to be a functional component
  • update StaticFilters to use new interface from answers-headless changes in this PR instead of managing its own filter state.
  • update filter utils to reflect the new interfaces from answers-headless
  • update AppliedFilters to use answers-headless setFilterOption function instead of performing a click event

J=SLAP-1661
TEST=manual

  • hook to local answers-headless changes, and start sample-app. See that filters work accordingly.

Yen Truong and others added 4 commits November 2, 2021 14:31
- update StaticFilters to be a functional component
- update StaticFilters to use new interface from answers-headless changes in this PR instead of managing its own filter state.
- update filter utils to reflect the new interfaces from answers-headless

Note: the package/answers-headless version will be updated once that pr is merged and publish.

J=SLAP-1661
TEST=manual

- hook to local answers-headless changes, and start sample-app. See that filters work accordingly.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 75.269% when pulling baceb00 on dev/filter-update into 7ea865e on main.

@@ -75,7 +75,12 @@ function RemovableFilter({ filter }: {filter: DisplayableFilter }): JSX.Element
}

const onRemoveStaticFilterOption = () => {
document.getElementById(`${filter.filter.fieldId + "_" + filter.filter.value}`)?.click();
if (!filter.filterCollectionId) {
Copy link
Contributor

@oshi97 oshi97 Nov 8, 2021

Choose a reason for hiding this comment

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

do we need this console.error if answers-headless also logs an error for this? maybe filterCollectionId should be a required field of DisplayableFilter

Copy link
Contributor Author

@yen-tt yen-tt Nov 8, 2021

Choose a reason for hiding this comment

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

filterCollectionId can't be required for DisplayableFilter since DisplayableFilter can also be use for type Facet or NLP filters, which doesn't have filterCollectionId. A check is needed here because Typescript would yell that filter.filterCollectionId can be undefined, which is not allow for function setFilterOption. I think it's ok to keep

@yen-tt yen-tt requested a review from oshi97 November 8, 2021 19:22
@yen-tt yen-tt merged commit 9ec7dbb into main Nov 8, 2021
@yen-tt yen-tt deleted the dev/filter-update branch November 8, 2021 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants