Skip to content

Fix: branch/repo dropdown reset on click#12501

Merged
hieptl merged 11 commits intoOpenHands:mainfrom
abhayymishraa:fix/branch-dropdown-reset-on-click
Jan 27, 2026
Merged

Fix: branch/repo dropdown reset on click#12501
hieptl merged 11 commits intoOpenHands:mainfrom
abhayymishraa:fix/branch-dropdown-reset-on-click

Conversation

@abhayymishraa
Copy link
Copy Markdown
Contributor

Summary of PR

This PR fixes cursor position jumping and input resetting issues in the branch and repository dropdown components.

Changes:

  1. Cursor position fix: Uses direct onChange handler instead of downshift's onInputValueChange to preserve cursor position when editing in the middle of input text (addresses downshift issue #217)

  2. Dropdown stability fix: Added stateReducer to both dropdowns to prevent dropdown from closing when clicking on the input field while it's open

  3. Input sync fix: Simplified useEffect logic to only sync input value with selected item when dropdown is closed, preventing text reset while user is typing

Demo Screenshots/Videos

Screen.Recording.2026-01-20.at.3.00.01.PM.mov

Change Type

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Other (dependency update, docs, typo fixes, etc.)

Checklist

  • I have read and reviewed the code and I understand what the code is doing.
  • I have tested the code to the best of my ability and ensured it works as expected.

Fixes

Resolves #12419

Release Notes

  • Include this change in the Release Notes.

Fixed cursor jumping to end of input when editing branch or repository names in dropdown search fields.

@hieptl
Copy link
Copy Markdown
Collaborator

hieptl commented Jan 21, 2026

Hello @abhayymishraa,

Thank you for your work on this pull request. Could you please add tests to cover the changes you’ve introduced? This will help ensure the behavior is well validated and prevent potential regressions in the future.

Please let us know if you need any support or clarification while adding the tests.

Thank you very much! 🙏

@abhayymishraa
Copy link
Copy Markdown
Contributor Author

Sure @hieptl

@abhayymishraa
Copy link
Copy Markdown
Contributor Author

Hi @hieptl , tests are failing because of the main branch test cases are failing

@hieptl
Copy link
Copy Markdown
Collaborator

hieptl commented Jan 22, 2026

Hello @abhayymishraa, I will review this pull request tomorrow. Thank you very much! 🙏

@abhayymishraa
Copy link
Copy Markdown
Contributor Author

Thank You @hieptl

@abhayymishraa
Copy link
Copy Markdown
Contributor Author

Hi @hieptl any update

Copy link
Copy Markdown
Collaborator

@hieptl hieptl left a comment

Choose a reason for hiding this comment

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

Thank you! 🙏

// Mock the repository data hook
const mockUseRepositoryData = vi.fn();
vi.mock(
"../../../../src/components/features/home/git-repo-dropdown/use-repository-data",
Copy link
Copy Markdown
Collaborator

@hieptl hieptl Jan 26, 2026

Choose a reason for hiding this comment

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

question: Would it be possible to use a pattern like this? Thank you! 🙏

vi.mock("#/components/.../use-repository-data", ...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry sorry, tab completion did that, will fix it

@abhayymishraa
Copy link
Copy Markdown
Contributor Author

@hieptl updated according to you!

@hieptl
Copy link
Copy Markdown
Collaborator

hieptl commented Jan 27, 2026

Thank you! 🙏

@hieptl hieptl merged commit b8a608c into OpenHands:main Jan 27, 2026
17 checks passed
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.

[Bug]: branch dropdown toggles on press, even when editing the branch via typing

2 participants