Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat WAI-ARIA - Modal dialog #1592

Merged
merged 1 commit into from Feb 16, 2016

Conversation

ymeine
Copy link
Contributor

@ymeine ymeine commented Feb 12, 2016

Mainly brings accessibility to modal dialogs.

Dialog features

Label (title)

Added the label information for the popup associated to the modal dialog. It is bound to the element containing the text of the latter's title.

Accessible icons

Features:

  • labels for icons can be specified: they will result in tooltips and aria labels
    • this implied opening a new property for icons allowing the specification of a label (the tooltip one was already existing)
  • icons are accessible using tab
  • icons react on "return" and "enter" keys, to trigger their action
  • the outline is displayed around icons when they are focused

Issues:

  • the "initial" outline width for Firefox is too big and does not correspond to the actual native outline we can see on focused elements
  • JAWS can't read properly the label of the first inserted icon (first in the DOM)

Glitches:

  • the tab order for icons is visually reversed, due to the floating positioning being contrary to the DOM insertion order

Background elements hiding

Features:

  • the elements of the body that visually resides behind the opened modal dialog are now ensured as hidden as long as the dialog is opened. These elements are restored to their previous state when the dialog is closed.

Glitches:

  • this feature implementation is limited to a sequence of modal dialogs that are closed in the reverse order of their opening.

Focus restoration

Features:

  • the element that was focused just before opening the dialog is memorized and the focus is put back on it when closing the dialog

Issues:

  • the icon reacts on the key down event: if the element on which the focus is put back opens the dialog upon the counterpart key up event (same key), it makes it impossible to close the dialog without having it opened again immediately afterwards

Glitches:

  • a simple reference to the native DOM element is internally saved: if this element instance is not present in the DOM anymore, this won't work (usually the case upon AT refreshes)

Side changes

fix - Action widgets (Button & Link)

Ensure keyup is handled only if keydown happened.

feat - WAI-ARIA - Icon

Features:

  • icons accept a new property to specify their labels
  • icons are accessible using tab
  • icons react on "enter" and "space" keys, to trigger their action
  • the outline is displayed around icons when they are focused

Issues:

  • the "initial" outline width for Firefox is too big and does not correspond to the actual native outline we can see on focused elements

feat - MultiSelect

The escape key now closes the dropdown.

fix - Fixed the escape behavior for several widgets

That way widgets such as the dialog can be closed with this key.

Now their associated controllers properly stop the behavior of the events as needed.

I had to add an additional property to the controllers' report model so that they can tell to prevent the default behavior of the browsers without making the propagation stop. This is needed to keep a bug fix while enabling the new behavior on escape.

var labelId = cfg.labelId;
if (labelId) {
html.push(' aria-labelledby="' + labelId + '"');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if role and labelId are not supposed to contain quotes, I think it is good, to be sure we don't have injections, to either escape (with the utilities from aria.utils.String) role and labelId or to use setAttribute once the DOM element is available.

@simonarbuckle simonarbuckle added this to the 1.7.17 milestone Feb 15, 2016
var attributes = [];

function addAttribute(key, value) {
attributes.push(key + '="' + value + '"');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value should be escaped here too.

@ymeine ymeine force-pushed the pr/feat/wai-aria/dialog/modal branch 2 times, most recently from 27675eb to e597d56 Compare February 15, 2016 17:05
ymeine added a commit to ymeine/ariatemplates that referenced this pull request Feb 15, 2016
Mainly brings accessibility to modal dialogs.

# Dialog features

## Label (title)

Added the label information for the popup associated to the modal dialog. It is bound to the element containing the text of the latter's title.

## Accessible icons

Features:

- labels for icons can be specified: they will result in tooltips and aria labels
	- this implied opening a new property for icons allowing the specification of a label (the tooltip one was already existing)
- icons are accessible using tab
- icons react on "return" and "enter" keys, to trigger their action
- the outline is displayed around icons when they are focused

Issues:

- the "initial" outline width for Firefox is too big and does not correspond to the actual native outline we can see on focused elements
- JAWS can't read properly the label of the first inserted icon (first in the DOM)

Glitches:

- the tab order for icons is visually reversed, due to the floating positioning being contrary to the DOM insertion order

## Background elements hiding

Features:

- the elements of the body that visually resides behind the opened modal dialog are now ensured as hidden as long as the dialog is opened. These elements are restored to their previous state when the dialog is closed.

Glitches:

- this feature implementation is limited to a sequence of modal dialogs that are closed in the reverse order of their opening.

## Focus restoration

Features:

- the element that was focused just before opening the dialog is memorized and the focus is put back on it when closing the dialog

Issues:

- the icon reacts on the key down event: if the element on which the focus is put back opens the dialog upon the counterpart key up event (same key), it makes it impossible to close the dialog without having it opened again immediately afterwards

Glitches:

- a simple reference to the native DOM element is internally saved: if this element instance is not present in the DOM anymore, this won't work (usually the case upon AT refreshes)

# Side changes

## fix - Action widgets (Button & Link)

Ensure keyup is handled only if keydown happened.

## feat - WAI-ARIA - Icon

Features:

- icons accept a new property to specify their labels
- icons are accessible using tab
- icons react on "enter" and "space" keys, to trigger their action
- the outline is displayed around icons when they are focused

Issues:

- the "initial" outline width for Firefox is too big and does not correspond to the actual native outline we can see on focused elements

## feat - MultiSelect

The escape key now closes the dropdown.

## fix - Fixed the escape behavior for several widgets

That way widgets such as the dialog can be closed with this key.

Now their associated controllers properly stop the behavior of the events as needed.

I had to add an additional property to the controllers' report model so that they can tell to prevent the default behavior of the browsers without making the propagation stop. This is needed to keep a bug fix while enabling the new behavior on escape.

----

closes ariatemplates#1592
@divdavem
Copy link
Member

🆗 e597d56 seems fine for me. You can integrate it once the travis build is 🆗

@ymeine ymeine force-pushed the pr/feat/wai-aria/dialog/modal branch from e597d56 to 5d8792e Compare February 15, 2016 17:45
ymeine added a commit to ymeine/ariatemplates that referenced this pull request Feb 15, 2016
Mainly brings accessibility to modal dialogs:

- label
- accessible icons
- background elements hiding
- focus restoration (to the latest focused element before opening the dialog) when closing the dialog

This required some side changes:

- now action widgets (Button & Link) make sure their action is trig erred only if the keyup event matches a previous keydown one
- icons are now accessible
- the MultiSelect widget can now be closed with the escape key
- various widgets have been fixed to handle the escape key more properly

closes ariatemplates#1592
Mainly brings accessibility to modal dialogs:

- label
- accessible icons
- background elements hiding
- focus restoration (to the latest focused element before opening the dialog) when closing the dialog

This required some side changes:

- now action widgets (Button & Link) make sure their action is triggered only if the keyup event matches a previous keydown one
- icons are now accessible
- the MultiSelect widget can now be closed with the escape key
- various widgets have been fixed to handle the escape key more properly

closes ariatemplates#1592
@ymeine ymeine force-pushed the pr/feat/wai-aria/dialog/modal branch from 5d8792e to 8cd4434 Compare February 16, 2016 07:40
@ymeine ymeine merged commit 8cd4434 into ariatemplates:master Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants