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

Toggle [aria-busy] instead of [busy] #157

Closed
wants to merge 1 commit into from

Conversation

seanpdoyle
Copy link
Contributor

Since <turbo-frame> elements are custom elements, the framework has
total control over the names of the attributes.

There are existing semantics for what we've introduced as [busy]: the
ARIA guidelines suggest toggling aria-busy="true" when an
element is loading more content, and aria-busy="false" when the
content is loaded.

This provides an "interface" for loading styles through CSS attribute
selectors, and hints to assistive technologies the state of the frame.

As an alternative, we could continue to toggle the [busy] attribute,
and encourage consumer applications to monitor mutations to the [busy]
attribute (or listen to turbo:frame-visit and turbo:frame-load
events
) to toggle it themselves.

src/core/frames/frame_controller.ts Outdated Show resolved Hide resolved
}

// Form submission delegate

formSubmissionStarted(formSubmission: FormSubmission) {

const frame = this.findFrameElement(formSubmission.formElement)
if (frame) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is frame ever not present? Looks like it falls back to this.element:

private findFrameElement(element: Element) {
const id = element.getAttribute("data-turbo-frame") || this.element.getAttribute("target")
return getFrameElementById(id) ?? this.element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@javan ah, I must've missed this while splitting out the separate [aria-busy] PR from the original: https://github.com/hotwired/turbo/pull/156/files#diff-8f44fafd854f6f716d51a2b05b5689266a9b66e0b1ad9d68570bd4e8cefd0a47R161

Since `<turbo-frame>` elements are custom elements, the framework has
total control over the names of the attributes.

There are existing semantics for what we've introduced as `[busy]`: the
ARIA guidelines suggest toggling [aria-busy="true"][aria-busy] when an
element is loading more content, and `aria-busy="false"` when the
content is loaded.

This provides an "interface" for loading styles through CSS attribute
selectors, and hints to assistive technologies the state of the frame.

As an alternative, we could continue to toggle the `[busy]` attribute,
and encourage consumer applications to monitor mutations to the `[busy]`
attribute (or listen to [`turbo:frame-visit` and `turbo:frame-load`
events][events]) to toggle it themselves.

[aria-busy]: https://www.w3.org/TR/wai-aria-1.1/#aria-busy
[events]: hotwired#59
@seanpdoyle seanpdoyle added enhancement New feature or request question Further information is requested labels Apr 1, 2021
@seanpdoyle seanpdoyle closed this Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Development

Successfully merging this pull request may close these issues.

2 participants