ember-a11y-refocus icon indicating copy to clipboard operation
ember-a11y-refocus copied to clipboard

Decide: should we add more flexibility for the way queryParams are handled for focus resets?

Open MelSumner opened this issue 3 years ago • 2 comments

Writing an issue so it can be discussed and decided.

Most of the issues I'm coming across are related to queryParams resetting the focus (as this addon intends to happen with a route navigation).

This causes some issues for things like, sorting an element where you don't want the focus to be reset after the sort. This leads me to wonder if the default for this should be false by default?

We still have some requirements:

  1. the queryParam should still be appended to the URL
  2. global to turn "please reset focus" for queryParam scenarios ON/OFF
  3. still allow exception list in either case.

So this, then, would support for four different scenarios:

  1. always reset focus for queryParam changes that affect the URL
  2. always reset focus for queryParam changes that affect the URL, but allow an exception list to be defined
  3. never reset focus for queryParam changes that affect the URL
  4. never reset focus for queryParam changes that affect the URL, but allow an exception list to be defined

MelSumner avatar Oct 06 '22 20:10 MelSumner

Having talked it through a bit, I think ignoring query-param-only transitions is a sensible default, but we should provide a friendly API for opting in to refocus behavior on certain query params. One example that jumps to mind is page, which is likely to be a good candidate for refocusing.

I’m picturing an API like this:

<NavigationNarrator
  @includeQueryParams={{array "page" "pageSize"}}
/>

Not sure what the API would be if you want to include all query params. Maybe:

<NavigationNarrator
  @includeQueryParams={{true}}
/>

jgwhite avatar Oct 11 '22 13:10 jgwhite

I'm not sure there's a right answer here. Whether we decide on resetting the focus or not, there will still have times when applications, using the addon, will need a way to add exceptions to the default behavior. Because it might make sense on applications or pages. So, no matter the solution (reset focus or not) we need to have a way to allow exceptions.

KamiKillertO avatar Oct 12 '22 07:10 KamiKillertO

As I was working on something that would accommodate this feature request, I realized that the custom validator function that we have can be used if you want to exclude a specific QP or set of QPs; what was being asked for could be done at a more all/nothing level. So I have a PR in that will exclude all QPs from this route transition/focus management if they turn that feature on.

I also added to the README some documentation for it, and that folks really shouldn't be doing this but maybe it makes sense with the way their apps are set up.

MelSumner avatar Jun 04 '24 18:06 MelSumner