Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Remove navbeforescroll? #36

Closed
Closed

Description

@hugoholgersson

Conceptually I see spatnav as a key-hook that runs in the browser just before arrow-key scrolling. If spatnav didn't find anything to focus, it lets the standard arrow-key scrolling do its job.

navnotarget could be used to signal: "spatnav's search failed, here's your chance to do something before we hand over control to the arrow-keys".

When handling navnotarget, authors would still be able to find out, by looking at the focused element's container's overflow, if a scroll is about to happen or not.

Activity

  1. anawhj commented on Mar 19, 2018

    @anawhj
    Collaborator

    onnavigate event seems the better approach than only supports of navbeforefocus and navnotarget. We can discuss with the issue in #32 as a single thread. How about this?

    In addition, both behaviors (scrolling and none) would have to be classified for authors. I prefer to support the three types in a same level.

  2. changed the title [-]Remove `navbeforescroll` and send `navnotarget` in its place?[/-] [+]Remove `navbeforescroll`?[/+] on Mar 19, 2018
  3. hugoholgersson commented on Mar 19, 2018

    @hugoholgersson
    Author

    In addition, both behaviors (scrolling and none) would have to be classified for authors.

    Is it really necessary to tell authors when spatnav is about to do arrow-key-scrolling? I think authors could get this kind of information by looking at the page layout (standard JS) from an onnavigate-handler.

    If we don't explicitly have to tell authors when spatnav is about to do arrow-key-scrolling, then the onnavigate-event could be simplified... I'd like the navigate-event to be as simple as possible because I'm thinking, in the future, that event could also be sent before sequential (= tab-key) navigation. The simpler it is, the higher chance I will become implemented across browsers.

  4. anawhj commented on Mar 19, 2018

    @anawhj
    Collaborator

    onnavigate-handler and three types of nav* handlers couldn't exist at the same time. It's a matter of choice. I'd like to briefly explain a use case using navbeforescroll event (or navigate event with a type of scroll).

    There is a container element that has several child elements with sparsely a bit long vertical scroll. When a user pushes a down arrow key and it's about to trigger scrolling due to no visible elements in that direction, the author wants not to scroll but to move the focus to one of invisible elements far away from a scrollport.

    In this situation, the author can use the navbeforescroll event so that the scrolling could be canceled by preventDefault() and the focus could be directly moved to the invisible element that the author wants with an implicit scrollIntoView. How about this use case? Apart from this, I could imagine several use cases using navbeforescroll. It seems to be separated from navnotarget. We can surely use the navigate event with a type of scroll to support this use case, but I hope to fix the choice for the smooth discussion. The choice could be easily reversed later.

    BTW, As you mentioned, navbeforescroll can't be used in the sequential navigation. It would be a great point against the 'nav*' handlers approach. However, in terms of the spatial navigation, navbeforescroll should be supported for reasons mentioned above in some form.

  5. hugoholgersson commented on Mar 19, 2018

    @hugoholgersson
    Author

    How about this use case?

    That's a good use case. Thanks! But isn't vanilla JS + a slim onnavigate capable of doing this?

    In this use case, a slim navigate-event would be sent with relatedTarget = null because no element will be focused by spatnav (spatnav will only trigger an arrow-key scroll). When an author sees the null, she could check the navigate-event's target's enclosing scroller. If it can scroll, that means spatnav will soon scroll it. With this information, she can decide to move focus manually with the same method: preventDefault() + betterElement.focus().

  6. anawhj commented on Mar 19, 2018

    @anawhj
    Collaborator

    Right, theoretically. The additional procedures for checking relatedTarget and a current scroll offset seem inconvenient, though I'm not in favor of vanilla JS.

  7. hugoholgersson commented on Mar 21, 2018

    @hugoholgersson
    Author

    I'm not in favor of vanilla JS.

    Right, but its hard to predict the popularity and usefulness of navbeforescroll. And since it can be pollyfilled via navigate, let's not include it in the spec's first round?

    As you mentioned, navbeforescroll can't be used in the sequential navigation.

    Yes. I believe we, at this point, only should add events and APIs that benefit and work with both spatial and sequential navigation... I believe that will make this API more popular and attractive.

  8. frivoal commented on Apr 2, 2018

    @frivoal
    Collaborator

    Based on the discussion above, and using example 5, example 6, and example 7, and in agreement with @jihyerish, I am closing #32 and #36 as no change.

    Further discussions with DOM people or the browser community may result in additional API changes, but for now, this is the design we're going with.

  9. added
    type:bug
    closed:duplicate
    on Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed:duplicatetopic:spectype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions