If keyboard control is a requirement, PrimeNG might not be the best fit. A structured evaluation of libraries against your requirements before choosing one is always a good idea.
If your best fit is still missing a requirement, like keyboard accessibility, your in luck if it's an OpenSource library: You can participate in it's development.
Head over to github and open a dialog with the package's maintainers. See if keyboard accessibility is on their agenda.
- Help testing keyboard interaction and file structured issues
- Make your most important components accessible yourself, and file a Pull Request
- Start a bounty for fixing your most important issues in the library
Concerning the issue at hand with focus on <body>
after picking a date:
For keyboard users it's often way faster to type in the date instead of picking it from a grid. As a UXP I observed users rock their numpad and enter dates faster than the date picker would slide in.
Since a date picker is to be considered as a dialog, the element that opened it should be focused on close
When a dialog closes, focus returns to the element that invoked the dialog […]
aria keyboard practices for dialog and date picker dialog example
You should keep this in mind for whatever workaround you find. One suggestion might be this:
- Bind to
onClose
of the date picker to focus the input
Additionally, you could apply
[showOnFocus]="false"
to allow typing the date in
- provide a
placeholder
to explain the expected format (and ideally a title
as well)
[showIcon]="true"
to still provide a dialog toggle
- focus the toggle after
onClose
instead of the input in that case