Skip to content

[2.x] fix: prevent search modal from opening when clear button is clicked#4595

Merged
imorland merged 1 commit intoflarum:2.xfrom
huoxin233:huoxin/2.x-clear-button-open-search
Apr 20, 2026
Merged

[2.x] fix: prevent search modal from opening when clear button is clicked#4595
imorland merged 1 commit intoflarum:2.xfrom
huoxin233:huoxin/2.x-clear-button-open-search

Conversation

@huoxin233
Copy link
Copy Markdown
Contributor

@huoxin233 huoxin233 commented Apr 20, 2026

Fixes #4593

Changes proposed in this pull request:

The .Search div in AbstractGlobalSearch has an onclick handler that opens the search modal. When the clear button inside the Input component is clicked, the event bubbles up to this handler, causing the search modal to open immediately after clearing the value.

This PR adds a guard in the onclick handler to check if the click originated from within the .Input-clear element and short-circuit before opening the modal.

Found a better solution
This PR modifies the Input component to call e.stopPropagation() inside the clear button's onclick handler. This will prevent the click from bubbling up to any parent container.

Reviewers should focus on:

Screenshot

Before:

PixPin_2026-04-20_23-21-23.mp4

After:

PixPin_2026-04-21_01-19-22.mp4

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.

Required changes:

  • Related documentation PR: (Remove if irrelevant)

@huoxin233 huoxin233 force-pushed the huoxin/2.x-clear-button-open-search branch from 8243ae2 to 9af7167 Compare April 20, 2026 17:55
@imorland imorland added this to the 2.0.0-rc.2 milestone Apr 20, 2026
@imorland imorland merged commit eff0932 into flarum:2.x Apr 20, 2026
19 checks passed
@huoxin233 huoxin233 deleted the huoxin/2.x-clear-button-open-search branch April 21, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Icon overlap in search bar and cancel button always open search modal

2 participants