The "Search repos..." field isn't automatically focused anymore when visiting the website #14633

Closed
opened 2025-11-02 11:18:25 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @pauschuu on GitHub (Jun 21, 2025).

Description

My workflow was:

  1. open my Gitea page
  2. type a few letters of a repo I'm working on
  3. press Enter
  4. having the correct repo open in Gitea

Since the upgrade on my server from Gitea 1.23.8 to 1.24.0 this doesn't work anymore.
The search field isn't select and I manually have to click it before I can type.

I am already on 1.24.2 now, the issue is still there.

Gitea Version

1.24.0, 1.24.2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Arch Linux

How are you running Gitea?

pacman -S gitea

Database

SQLite

Originally created by @pauschuu on GitHub (Jun 21, 2025). ### Description My workflow was: 1) open my Gitea page 2) type a few letters of a repo I'm working on 3) press Enter 4) having the correct repo open in Gitea Since the upgrade on my server from Gitea 1.23.8 to 1.24.0 this doesn't work anymore. The search field isn't select and I manually have to click it before I can type. I am already on 1.24.2 now, the issue is still there. ### Gitea Version 1.24.0, 1.24.2 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System Arch Linux ### How are you running Gitea? pacman -S gitea ### Database SQLite
GiteaMirror added the type/bug label 2025-11-02 11:18:25 -06:00
Author
Owner

@pauschuu commented on GitHub (Jun 21, 2025):

Look at commit 085f273d19

They changed

      this.$refs.search.focus();

to

      this.$refs.search?.focus();

Maybe that could be the culprit?

Changing from this.$refs.search.focus(); to this.$refs.search?.focus(); introduces optional chaining, meaning focus() will only be called if this.$refs.search is defined at that moment. If, due to changes elsewhere, the reference isn't available immediately (for example, because the input isn't yet rendered when the focus is attempted), the focus call will silently do nothing.

@pauschuu commented on GitHub (Jun 21, 2025): Look at commit 085f273d19a30cc7cb7f6315a15a95c2b59fc5b9 They changed ``` this.$refs.search.focus(); ``` to ``` this.$refs.search?.focus(); ``` Maybe that could be the culprit? Changing from `this.$refs.search.focus();` to `this.$refs.search?.focus();` introduces optional chaining, meaning `focus()` will only be called if `this.$refs.search` is defined at that moment. If, due to changes elsewhere, the reference isn't available immediately (for example, because the input isn't yet rendered when the `focus` is attempted), the `focus` call will silently do nothing.
Author
Owner

@wxiaoguang commented on GitHub (Jun 21, 2025):

Maybe that could be the culprit?

Yes.

Old code: the input is always there. So it can always get focus.
New code: the input will only be there when the data gets loaded. So the search?.focus() is a no-op because the data can't be ready in that short time.

@wxiaoguang commented on GitHub (Jun 21, 2025): > Maybe that could be the culprit? Yes. Old code: the input is always there. So it can always get focus. New code: the input will only be there when the data gets loaded. So the `search?.focus()` is a no-op because the data can't be ready in that short time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14633