Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#4413 closed task (fixed)

create dijit routine to find first/last focusable item in a container

Reported by: Becky Gibson Owned by: simonjb
Priority: high Milestone: 1.1
Component: Accessibility Version: 0.9
Keywords: Cc: davidb
Blocked By: Blocking:

Description

There are cases where it would be useful to know the first/last focusable item in a container. Ticket #4411 would need this as well as ctrl-pageup/pagedown from within a tab pane to move to the next pane. Currently focus is set to a specific item (in the case of dialog the title, tooltip dialog the dialog container, tab pane navigation the tab title) but it would be better to set focus to a specific item as long as performance is not affected.

I have set this to 1.0 but it could be pushed to 1.1 if necessary.

Attachments (1)

4413b.diff (16.2 KB) - added by simonjb 12 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 12 years ago by Becky Gibson

possible query: dojo.query().foreach ( try { elm.focus(); } catch(e) { not this one } );

comment:2 Changed 12 years ago by bill

I hate to see spurious exceptions... I'd like to say to just query <button>, <input>, <textarea>, and <a> nodes (did I forget anything?) but I guess that we also have to look for anything with tabIndex >= 0 (although that seems like an uncommon case). Also need to ignore and <button>, <input> etc with tabIndex < 0.

Alernately maybe could simulate a tab keypress and see where focus goes.

comment:3 Changed 12 years ago by davidb

Cc: davidb added

comment:4 Changed 12 years ago by Becky Gibson

candidate for moving to 1.1 but would really like to implement for 1.0

comment:5 Changed 12 years ago by Becky Gibson

Milestone: 1.01.1

comment:6 Changed 12 years ago by simonjb

Owner: changed from Becky Gibson to simonjb
Status: newassigned

Changed 12 years ago by simonjb

Attachment: 4413b.diff added

comment:7 Changed 12 years ago by simonjb

Attached a patch of where I am at so far in terms of an implementation:

  • includes both a set of functions (findFirstTabDocOrder, findLastTabDocOrder) which search strictly in doc order without considering tabindex > 0 as a special case and a set of functions (findFirstTab, findLastTab) which do consider tabindex > 0 as special
  • includes a modification to themeTester.html for timing the functions

Still to do:

  • do we want both the set of functions that treat tabindex > 0 specially and the set that don't?
  • what to do for Safari and other browsers that don't support tabindex == -1 and tabindex on all elements? one solution would be to try to focus, if get an exception then keep looking, this would be easy for the set that don't treat tabindex > 0 specially but for the set that does we would need to store the elements that we have visited so that we can try them in order
  • fix up API
  • optimise

comment:8 Changed 12 years ago by simonjb

Another option for dealing with Safari would be simply to fail -- try to focus the element that we think should get focus and if it doesn't work, give up and leave focus where it was.

comment:9 Changed 11 years ago by simonjb

Resolution: fixed
Status: assignedclosed

(In [12001]) Implemented functions to find the first and last tab-navigable elements. Fixes #4413.

comment:10 Changed 11 years ago by Adam Peller

are these routines specific to tabs? Should it be moved out of common code?

comment:11 Changed 11 years ago by simonjb

@peller, they aren't specific to dijit tab containers -- maybe I could rename the functions to make their purpose clearer. They find tab-navigable elements in a container (tab as in tab key, tab stop, tabindex). Maybe if I rename to:

  • _findTabStops()
  • findFirstTabStop()
  • findLastTabStop()

How would that work?

comment:12 in reply to:  11 Changed 11 years ago by Adam Peller

Replying to simonjb:

@peller, they aren't specific to dijit tab containers -- maybe I could rename the functions to make their purpose clearer. They find tab-navigable elements in a container (tab as in tab key, tab stop, tabindex). Maybe if I rename to:

  • _findTabStops()
  • findFirstTabStop()
  • findLastTabStop()

Sorry, I obviously didn't look very closely. But yeah, maybe that would help.

comment:13 Changed 11 years ago by simonjb

(In [12042]) Renamed dijit.findFirstTab to dijit.getFirstInTabbingOrder, dijit.findLastTab to dijit.getLastInTabbingOrder, and dijit._findTabs to dijit._getTabNavigable. Refs #4413.

Note: See TracTickets for help on using tickets.