nextcloud-vue icon indicating copy to clipboard operation
nextcloud-vue copied to clipboard

feat(NcModal): expose `initialFocus` prop for focus-trap options

Open Antreesy opened this issue 2 months ago • 6 comments

☑️ Resolves

  • Exposing initialFocus and setReturnFocus to NcModal and NcDialog consumers
    • See https://github.com/focus-trap/focus-trap#initialfocus
    • Allows to manipulate initial focus (e.g. in case first element in the trap is NcSelect and we don't want it to be open)

🖼️ Screenshots

🚧 Tasks

🏁 Checklist

  • [ ] ⛑️ Tests are included or are not applicable
  • [ ] 📘 Component documentation has been extended, updated or is not applicable
  • [ ] 2️⃣ Backport to stable8 for maintained Vue 2 version or not applicable

Antreesy avatar Oct 01 '25 08:10 Antreesy

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 52.20%. Comparing base (49763e7) to head (8afa991).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7587   +/-   ##
=======================================
  Coverage   52.20%   52.20%           
=======================================
  Files         101      101           
  Lines        3174     3174           
  Branches      871      872    +1     
=======================================
  Hits         1657     1657           
  Misses       1271     1271           
  Partials      246      246           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 25 '25 15:11 codecov[bot]

I forgot about that PR🪦 Shall we get it in?

Antreesy avatar Nov 25 '25 15:11 Antreesy

Was it for the translation dialog in chat?

DorraJaouad avatar Dec 03 '25 09:12 DorraJaouad

Yes, in general it fits for any dialog that does not need to have an initial focus on the child element

Antreesy avatar Dec 03 '25 09:12 Antreesy

  • (e.g. in case first element in the trap is NcSelect and we don't want it to be open)

With a small CSS fix, and by using available props and events we can make NcSelect open only manually but not by focus.

Would it also work for you?

ShGKme avatar Dec 04 '25 18:12 ShGKme

we can make NcSelect open only manually but not by focus. Would it also work for you?

Depends on how it changes current default behaviour, and what app developers should do to implement it. I'd take a look =)

Antreesy avatar Dec 05 '25 08:12 Antreesy