8000 Dropdown rerenders and input loses focus on change after v5.6.0 · Issue #438 · coreui/coreui-react · GitHub
[go: up one dir, main page]

Skip to content
Dropdown rerenders and input loses focus on change after v5.6.0 #438
Open
@PrzemyslawChudzia

Description

@PrzemyslawChudzia

Description:
After upgrading to coreui-react v5.6.0, the dropdown component rerenders whenever an input inside the dropdown is changed (e.g., typing in a text field).

It seems related to this change:
v5.5.0...v5.6.0#diff-2d524df48f938b94012faeccfcd7c2d5ad4d297e1b3f46a9357eee1fb68747b1R241-R279

That change adds more dependencies to the useEffect. When inputs inside the dropdown change, new references are created and the effect re-runs, which triggers the cleanup function. This destroys the popper instance, calls onHide, and removes event listeners — effectively rerendering the dropdown.

Repro link:
https://codesandbox.io/p/devbox/intelligent-lehmann-r5z5y8?workspaceId=ws_DikbXRwHoGrNt9M6NXuZNR

Steps to reproduce:

  1. Open the repro sandbox.
  2. Click the dropdown to open it.
  3. Type into the input field inside the dropdown.
  4. Notice the dropdown rerenders and the input loses focus.

Expected behavior:
Typing into an input inside the dropdown should not cause the dropdown to rerender or close, and the input should retain focus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0