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

hacky way to keep unpermitted params out of text range facet links #298

Merged
merged 4 commits into from
Dec 3, 2024

Conversation

jrochkind
Copy link
Member

It seems like there should be a better way -- I thought Blacklight search_state was only including allow-listed params in the first place but apparently not? Not sure what a better way would be or if it would require Blacklight architectural changes, but this works for now. Regression test included that was red without this change.

Closes #296

@jrochkind jrochkind changed the title hacky way to keep unpermitted params out of text facet links hacky way to keep unpermitted params out of text range facet links Nov 27, 2024
@jrochkind jrochkind marked this pull request as draft December 2, 2024 04:43
@jrochkind jrochkind changed the base branch from main to fix_tests December 2, 2024 18:10
@jrochkind jrochkind force-pushed the avoid_unpermitted_params_in_text_facet branch from 20e74ee to fe21b13 Compare December 2, 2024 18:15
@jrochkind jrochkind changed the base branch from fix_tests to main December 2, 2024 18:16
@jrochkind jrochkind force-pushed the avoid_unpermitted_params_in_text_facet branch from fe21b13 to 5846791 Compare December 2, 2024 18:16
@jrochkind
Copy link
Member Author

OK, I learned more about what's going on. Blacklight SearchState does have an allow-list, such that un-mentioned params are ignored.

But we had to ADD our special range params into the allow-list, to get them available for use in the builder where we needed them.

included do
before_action do
# Blacklight 7.25+: Allow range limit params if necessary
if blacklight_config.search_state_fields
missing_keys = RANGE_LIMIT_FIELDS - blacklight_config.search_state_fields
blacklight_config.search_state_fields.concat(missing_keys)
end
end
end

But we want them ONLY in the #range_limit action -- we don't want them forwarded on when we generate facet links to typical catalog action.

I actually can't see any better way to get that to happen then with the overide in FaceItemPresenter.

BUT, two improvements as a result of this investigation:

  • We can move the per-action addition of our #range_limit-specific allowed search params into that method to effect only that action, and not effect #index or any actions in the host controller, much more careful!

  • We can re-use the constant that already held the keys of those params, when we strip them out in FacetItemPresenter, to keep the list DRY.

It seems like there should be a better way -- I thought Blacklight search_state was only including allow-listed params in the first place but apparently not?  Not sure what a better way would be or if it would require Blacklight architectural changes, but this works for now. Regression test included that was red without this change.
@jrochkind jrochkind force-pushed the avoid_unpermitted_params_in_text_facet branch from 123d442 to be56b23 Compare December 2, 2024 19:57
@jrochkind jrochkind marked this pull request as ready for review December 2, 2024 20:14
@jrochkind
Copy link
Member Author

@seanaery after this one, I'll release a beta2 -- and hope to be done!

@seanaery
Copy link
Collaborator

seanaery commented Dec 3, 2024

This looks to me like a reasonable way to address the issue, even if it is imperfect. Thanks for figuring it out. The test is helpful and I like that this isolates the params the plugin needs to permit within the range_limit action.

@seanaery seanaery merged commit 2788b4c into main Dec 3, 2024
9 checks passed
@seanaery seanaery deleted the avoid_unpermitted_params_in_text_facet branch December 3, 2024 13:55
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.

Clicking on a textual "Range List" facet does not meet Blacklight controller StrongParams requirements
2 participants