blacklight
blacklight copied to clipboard
It's difficult to override a method in FacetItemComponent globally
User story
As a developer, I would like to make a small customization to the "x" remove icon button in all facets.
Current options
When I tried to do this for my app, I considered a few options, none of which seem very satisfactory:
- I could create a custom component that inherits from
FacetItemComponent. Then, every time I callconfig.add_facet_fieldin my catalog controller, I could additem_component: MyCustomItemComponent. The downside is that my app has 77 lines like this; it would be easy to miss one and end up with an inconsistent display. - I could copy the entire contents of
FacetItemComponentinto place at my app'sapp/components/blacklight/facet_item_component.rb. But this seems excessive, since I only want to override a single method.
Proposal
For this particular use case, it would be convenient to have a configuration option, so I could set something like this in the catalog controller:
config.default_facet_item_component = MyCustomItemComponent
And still allow individual FacetFields to override the default.
But, I could also be missing something, or maybe we could come up with a better API that would enable this use case -- feedback very welcome.