Skip to content

fix: #2767 Search field loses focus after search#2870

Merged
Chartman123 merged 1 commit into
mainfrom
bugfix/2767-Search-field-loses-focus-after-search
Sep 9, 2025
Merged

fix: #2767 Search field loses focus after search#2870
Chartman123 merged 1 commit into
mainfrom
bugfix/2767-Search-field-loses-focus-after-search

Conversation

@Koc
Copy link
Copy Markdown
Collaborator

@Koc Koc commented Aug 17, 2025

This PR closes #2767. Better to review with ignored whitespaces and in split view

nextcloud-forms-2025-08-19_21.39.03.mp4

@Koc Koc force-pushed the bugfix/2767-Search-field-loses-focus-after-search branch from 17c3903 to e0b9772 Compare August 17, 2025 22:35
@Koc Koc requested a review from Chartman123 August 17, 2025 22:37
@Koc Koc force-pushed the bugfix/2767-Search-field-loses-focus-after-search branch from e0b9772 to 57a01f1 Compare August 17, 2025 22:42
@Koc Koc requested a review from susnux August 17, 2025 22:42
@Koc
Copy link
Copy Markdown
Collaborator Author

Koc commented Aug 17, 2025

Mates, I don't know how to fix eslint, please help 🙏

Copy link
Copy Markdown
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

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

The lint error comes from a wrong filename in the import :)

Comment thread src/utils/debounce.js Outdated
Comment thread src/utils/debounce.js Outdated
Copy link
Copy Markdown
Collaborator

@susnux susnux left a comment

Choose a reason for hiding this comment

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

I do not see how this fixes the issue - it just delays it

@Koc Koc force-pushed the bugfix/2767-Search-field-loses-focus-after-search branch from bf4646e to 2025561 Compare August 19, 2025 19:41
@Koc
Copy link
Copy Markdown
Collaborator Author

Koc commented Aug 19, 2025

@susnux mate, I properly tested PR before submitting. To prove that fix works I've added a video to the PR description. There is only one case when we're loosing focus: by click of "clear" button. But I'm pretty sure that its normal behavior of ui library.

I'm using latest version of the Firefox on Ubuntu. But it was tested also on Chrome.

@Chartman123
Copy link
Copy Markdown
Collaborator

@susnux Could it be that the issue was caused by the order of elements? Especially the NcEmptyContent before the Header and the if/else branches within the template?

The debounce was there before, too.

@Koc yes, please stick with the debounce function and remove the custom utils/debounce.js

Comment thread src/views/Results.vue Outdated
@Koc Koc force-pushed the bugfix/2767-Search-field-loses-focus-after-search branch 3 times, most recently from a264363 to 7b309a4 Compare September 7, 2025 13:54
@Koc
Copy link
Copy Markdown
Collaborator Author

Koc commented Sep 7, 2025

@Chartman123 @susnux guys, it not works as expected without this new debouncedProperty that I've added in current PR.

The main difference of this computed property comparing to the old implementation is that now we're delaying write to submissionSearch. Previously we write immediately but delay reading (watch).

Here an video which shown that we're still loosing focus when submissionSearch was cleared quickly right after there were no search results. At the same time debouncedProperty works fine for that scenario.

nextcloud-forms-2025-09-07_15.58.56.mp4

@Chartman123
Copy link
Copy Markdown
Collaborator

@Koc your latest commit is reverting changes to the icons. Please keep the changes to use the outlined icons :)

@Koc Koc force-pushed the bugfix/2767-Search-field-loses-focus-after-search branch 2 times, most recently from 1f6cc5b to 6c1cdda Compare September 8, 2025 14:36
@Koc
Copy link
Copy Markdown
Collaborator Author

Koc commented Sep 8, 2025

@Chartman123 good catch! It happened during conflict resolution. Now should be better, please check one more time

@Chartman123
Copy link
Copy Markdown
Collaborator

Chartman123 commented Sep 9, 2025

@Koc I think I found a solution for keeping our default "debounce" function and eliminating the focus loss. We have to switch the condition for disabling the PillMenu, the search <div> and the "No submissions" NcEmptyContent from noSubmissions to form.submissionCount === 0.

I changed noSubmissions to be based on the form.submissionCount and introduced a new noFilteredSubmissions that is based on this.submissions.length.

With that change we don't have to rely on the debouncing but fix the root cause of the focus loss by removing unneccessary re-renders.

I added a commit to your PR. Please review and test it 🙂

@Koc
Copy link
Copy Markdown
Collaborator Author

Koc commented Sep 9, 2025

@Chartman123 It works! Thank you

@Chartman123
Copy link
Copy Markdown
Collaborator

@Koc great :) You can just squash the two commits into one and then we can merge the fix 👍🏻

Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc Koc force-pushed the bugfix/2767-Search-field-loses-focus-after-search branch from de03b30 to a96912a Compare September 9, 2025 15:09
@Chartman123 Chartman123 merged commit a5c39fe into main Sep 9, 2025
48 checks passed
@Chartman123 Chartman123 deleted the bugfix/2767-Search-field-loses-focus-after-search branch September 9, 2025 17:01
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.

Search field loses focus after search

3 participants