asset-share-commons icon indicating copy to clipboard operation
asset-share-commons copied to clipboard

Issue with Asset Share Commons - Dynamic Facet Filter

Open vinaykhurana opened this issue 7 years ago • 2 comments

We at Microsoft have a Facet Filter component which displays multiple items as checkbox to filter Assets on Asset Share page. When selection of any filter item results in reducing the number of filter items (as per the filtered result set), we lose the state of selected facet items on any further action on Search page. Attached document has the detailed explanation of the problem and a proposed solution to fix it in Asset Share Commons.

Issue with Asset Share Commons Dynamic Filters.docx

@kaushalmall @reenakumarii

vinaykhurana avatar Jun 13 '18 06:06 vinaykhurana

@vinaykhurana yeh - this is a tricky situation .. have you tried calling reset() as suggested? Are there any other side effects?

Ill have to revisit the code - but the general approach is that the DOM is the canonical source for search state, vs trying to maintain that over "time" in JS, so on paper this seems reasonable -- ie. events should always go back to the DOM anyhow -- that being said, there might be caveats I'm forgetting.

davidjgonzalez avatar Jun 13 '18 13:06 davidjgonzalez

@davidjgonzalez using reset() worked. But we found some other way to fix the issue. In the facet component we are using, instead of assigning the index based on the list index, we moved the item index assigning logic to model side. What that means is, if an item had index 1 before applying any filter, we keep the same index of selected item after filters are applied. In the example which i mentioned in the problem statement, we assign the index 1 to 'prh-campaign' facet item even though this is the only item left after applying filters.

I din't like this approach of assigning index this way but this was the only option at that moment to fix it without a change in asset-share-commons. Ideally asset-share-commons should be handling dynamic filters like this where applying of a filter item results in reduced set of filter items.

CC : @kaushalmall @reenakumarii

vinaykhurana avatar Jun 27 '18 04:06 vinaykhurana