Skip to content

fix: focus the first input when opening text entry modals - #4089

Open
AlexAndBear wants to merge 1 commit into
mainfrom
fix/modal-initial-input-focus
Open

AlexAndBear wants to merge 1 commit into
mainfrom
fix/modal-initial-input-focus

Conversation

@AlexAndBear

Copy link
Copy Markdown
Member

Description

  • Initial focus: modals where you type something now focus their first field when they open, like "New space" and "New folder" already do: new user, new group, new shortcut, link password, change password, new app token, set expiration date and the Collabora "Save as" / "Export as" file name. New user and new group lost this in a refactor, the others never had it.
  • Modal focus handling: when a modal sets its initial focus via a selector, the focus now stays put when a nested info drop closes instead of jumping back into the field, and it falls back to the modal body if the field is gone (e.g. after creating an app token) instead of throwing.

Related Issue

How Has This Been Tested?

  • test environment: unit tests (Vitest), browser tests (Playwright) against a local OpenCloud
  • test case 1: unit: every changed modal dispatches the right initial focus selector, and the selector targets the first input of its component
  • test case 2: unit: OcModal with the real focus trap: selector focuses the element in its own modal, focus returns to the info drop toggle after closing it, focus falls back to the modal body when the target is removed
  • test case 3: browser: all changed modals focus their field when opened by mouse and keyboard; info drop focus return, app token creation, stacked modals and the modals that already worked (new space/folder/file, rename, OCM, crop, unsaved changes, confirmations) behave as before

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

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.

Text entry modals don't focus their first input

1 participant