Skip to content

Conversation

@danxuliu
Copy link
Member

In the past the (now legacy) unified search was explicitly cleared on navigation changes in the Files app (for example, when changing sections between All files and Recent).

This is no longer the case in the current unified search, as neither file:navigation:changed is subscribed to reset the search nor nextcloud:unified-search:clear is emitted when the navigation changes in the Files app.

However, turns out that just closing the modal was intended to clear the query. Due to that there would be no need to explicitly clear it on navigation changes, but clearing the query when closing the modal was not working as expected.

The problem was that update:query was not emitted by UnifiedSearchModal when its internal query value (searchQuery) was modified (I guess that update:searchQuery was emitted instead, but I have not actually checked it), so UnifiedSearch.query was not updated when the query changed in the modal. Due to that UnifiedSearch.query was always an empty string, so when the modal was closed and an empty string was explicitly set this did not change its value, the watcher for query was not triggered and searchQuery was not updated to the empty string, so the search in the modal was not cleared.

For reference, updating the query worked fine in UnifiedSearchLocalSearchBar.

How to test

  • Open the Files app
  • Open the unified search
  • Search for something
  • Close the unified search
  • Open the unified search again

Result with this pull request

The previous search term and results are gone

Result without this pull request

The previous search term and results are still there

@danxuliu danxuliu added this to the Nextcloud 32 milestone Jul 16, 2025
@danxuliu
Copy link
Member Author

/backport to stable31

@danxuliu
Copy link
Member Author

/backport to stable30

@nextcloud-command nextcloud-command force-pushed the fix-clearing-unified-search-when-modal-is-closed branch from aa94c02 to a8a9a4e Compare July 16, 2025 05:38
The unified search modal was intended to be cleared when closed.
However, "UnifiedSearchModal" did not emit "update:query" when its
internal query value ("searchQuery") changed, so "UnifiedSearch.query"
was kept as an empty string. When the modal was closed "update:query"
was emitted with an empty string, which should have cleared
"UnifiedSearch.query" and that, in turn, should have cleared the modal.
However as "UnifiedSearch.query" was already an empty string the watcher
that updates "UnifiedSearchModal.searchQuery" from "UnifiedSearch.query"
was not triggered and the modal was not cleared.

As "UnifiedSearch.query" is now updated with the value of
"UnifiedSearchModal.searchQuery" the latter can not be trimmed when
updated from the former, as that would in turn also trim
"UnifiedSearchModal.searchQuery" and prevent to search for anything with
spaces at the beginning or end (even if those trailing spaces are just
temporary while writing something like "searched value").

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@danxuliu danxuliu force-pushed the fix-clearing-unified-search-when-modal-is-closed branch from a8a9a4e to cf337a7 Compare July 16, 2025 11:06
@danxuliu
Copy link
Member Author

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@danxuliu danxuliu added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jul 16, 2025
@danxuliu danxuliu marked this pull request as ready for review July 16, 2025 15:25
@danxuliu danxuliu requested review from a team as code owners July 16, 2025 15:25
@danxuliu danxuliu requested review from nfebe, skjnldsv, susnux and szaimen and removed request for a team July 16, 2025 15:25
Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

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

Tested and works :)

@danxuliu danxuliu merged commit 8fc37b2 into master Jul 17, 2025
137 of 140 checks passed
@danxuliu danxuliu deleted the fix-clearing-unified-search-when-modal-is-closed branch July 17, 2025 11:40
@skjnldsv skjnldsv mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
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.

5 participants