primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Component: Dynamic Dialog should not focus first focusable element on close

Open jonnomk opened this issue 6 months ago • 0 comments

Describe the bug

Currently, if I open a dynamic dialog and scroll to the bottom of the content in the case where a scrollbar is shown and then click a button that opens another dialog, the first focusable element is focused. The problem is, if that element is above the fold of the scrolled area, when focus is applied, the content whips back up to the top which is not good UX.

It didn't do this on version 15. I have recently upgraded to version 17.18.9 and the problem exists there.

The problem is with this code in dynamicdialog.ts:

image

The assumption is being made that we want to focus the first element on close. Perhaps we can add a new property focusOnHide and set it to false by default so that it's not a breaking (breaking the UX) change?

Environment

Windows 11

Reproducer

No response

Angular version

18.1.2

PrimeNG version

17.18.9

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.19.0

Browser(s)

All

Steps to reproduce the behavior

No response

Expected behavior

The dialog should close and the dialog beneath it (previous dialog) shouldn't scroll to the top due to an element being focused.

jonnomk avatar Aug 19 '24 18:08 jonnomk