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

Allow extensions to modify MIN_SEARCH_LENGTH in Search component #3130

Merged
merged 1 commit into from
Oct 30, 2021

Conversation

dsevillamartin
Copy link
Member

Fixes #3129

Changes proposed in this pull request:

  • Use this.constructor instead of accessing the parent class directly to allow subclasses to modify MIN_SEARCH_LEN static

Reviewers should focus on:

  • Perhaps clarifying wording of docblock

Screenshot
No user facing changes in core itself. This is helpful for fof/merge-discussions, changing the min search length to 1:

image

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Copy link
Sponsor Member

@askvortsov1 askvortsov1 left a comment

Choose a reason for hiding this comment

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

I've thught about this one a bit, and I think that once we have #3127 (review) and adding settings defaults has much less overhead, we should put this into a setting instead. We don't need an admin UI for it necessarily, but having it implemented as a setting would make customization easier.

@dsevillamartin
Copy link
Member Author

dsevillamartin commented Oct 27, 2021

@askvortsov1 This is not intended to modify the min search length of the navbar search bar - that can be done already by modifying Search.MIN_SEARCH_LEN through any JS code.

This is for extensions that extend the component and want a different minimum search length for their own custom search bar. The logic for searching is all cluttered in oncreate and event hooks and so requires a lot of code to be copy & pasted to change that as of now.

I agree a setting would be nice, but that wouldn't address different search components used by extensions and their intended use cases.

@dsevillamartin dsevillamartin merged commit f260bd7 into master Oct 30, 2021
@dsevillamartin dsevillamartin deleted the ds/3129-use-constructor-min-search-len branch October 30, 2021 23:13
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.

Allow extensions to modify the minimum search length in the Search component
3 participants