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

Migrate lang attributes to iframe documents and remove default #764

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

austinmatherne-wk
Copy link
Contributor

@austinmatherne-wk austinmatherne-wk commented Nov 20, 2024

Reason for change

Reopening #684. The previous discussion moved into changing the application language. That feature is being handled by another effort.

Description of change

We currently set the lang attribute to a default of en-US for non stub viewers. This change removes the default and migrates the attribute from the root html element to the report iframe.

Steps to Test

  • Use a report with a non English xml:lang value.
  • Verify that the lang attribute is not set on either the root or iframe html elements when used with and without the stub viewer.
  • Verify that the xml:lang attribute is set on the iframe html document and not on the root html element when the stub viewer is used.

review:
@Arelle/arelle
@paulwarren-wk

@austinmatherne-wk austinmatherne-wk requested a review from a team as a code owner November 20, 2024 11:26
@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

if ($('html').attr("lang") === undefined) {
$('html').attr("lang", "en-US");
if ($('html').attr("xml:lang") !== undefined ) {
$(iframe).contents().find('html').attr("xml:lang", $('html').attr("xml:lang"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused. The original logic was added in commit c3d517e, which I thought was specifically adding lang="" for accessibility tools, so it seems like we need to keep $('html').attr('lang',?

I don't understand why we need to change $(iframe) at all. If that's also needed for accessibility, it seems like it should also be done in load?

(Whatever is decided, a comment of some kind would be helpful.)

Copy link
Contributor Author

@austinmatherne-wk austinmatherne-wk Nov 21, 2024

Choose a reason for hiding this comment

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

The lang attribute was likely added to pass an automated accessibility checker that ensures a lang value is defined, but it didn’t verify whether the lang attribute accurately reflects the content.

There’s an open support ticket regarding this issue. I don’t have strong preferences for the final implementation, as long as we stop labeling French content as American English.

Copy link
Contributor

Choose a reason for hiding this comment

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

The lang="en-US" seems like the correct default for the application. It was always correct prior to commit 9cb2512, but perhaps it's not correct after i18nInit runs. Perhaps setLanguage should also be updating $('html').attr('lang') to match the selected application language?

If we need to copy attributes into the iframe (I'm not sure if xml:lang has any meaning given that we know from the accessibility ticket that xml:lang wasn't good enough.. ?), it seems like we should copy all attributes like we do for body below.

Copy link
Contributor Author

@austinmatherne-wk austinmatherne-wk Nov 23, 2024

Choose a reason for hiding this comment

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

I tested all major desktop screen readers and observed three distinct behaviors:

  1. All languages are treated the same, using a single, user selected voice.
  2. Screen readers inspect the content to determine the language, ignoring both lang and xml:lang attributes (though these might be fallback options if the language can’t be inferred from the content).
  3. The lang attribute is used, while the xml:lang attribute is ignored.

In none of the tools did I find the xml:lang attribute being used. Additionally, the presence of content within an iframe or serving the document as XHTML made no difference to the behavior.

Based on these findings, I propose the following approach:

  1. For the non-stub viewer, migrate all attributes on the root html node to the html element of the report iframe (including xml:lang).
  2. For both stub and non-stub viewers, set the lang attribute of the report iframe’s html element to the value of the report’s xml:lang attribute (if present).
  3. Set the lang attribute of the root html node to match the application UI language.
  4. If we don't know the report language because the report lacks an xml:lang value, set the lang attribute of the report iframe’s html element to an empty string. This effectively “resets” the language and prompts the screen reader to use its default voice instead of the application language.
  5. Within the inspector, override the lang attribute on taxonomy content elements with the selected taxonomy language.

Copy link
Contributor

@brettkail-wk brettkail-wk Nov 25, 2024

Choose a reason for hiding this comment

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

  1. Screen readers inspect the content to determine the language, ignoring both lang
  2. The lang attribute is used

These seem contradictory. Can you clarify?

  1. Within the inspector, override the lang attribute on taxonomy content elements with the selected taxonomy language.

I didn't follow this. Could you give an example?

Otherwise, 1-4 sound good to me, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These seem contradictory. Can you clarify?

They are. The listed behaviors are from different screen readers. A few examples:

  1. NVDA - All languages are treated the same
  2. macOS VoiceOver - inspects the content to determine the language
  3. JAWS - Uses the lang attribute

I didn't follow this. Could you give an example?

Taxonomy labels, references, etc. There are three languages in the viewer and the lang attributes should reflect that.

  1. The report content (report iframe)
  2. The selected application UI language (inspector panel)
  3. The selected taxonomy language (labels )

$('html').attr("lang", "en-US");
if ($('html').attr("xml:lang") !== undefined ) {
$(iframe).contents().find('html').attr("xml:lang", $('html').attr("xml:lang"));
$('html').removeAttr("xml:lang");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why this is needed.

Copy link
Contributor Author

@austinmatherne-wk austinmatherne-wk Nov 21, 2024

Choose a reason for hiding this comment

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

The xml:lang value defined for the report doesn't necessarily match the language of the viewer UI, so keeping it at the root html level seems inappropriate. The report xml:lang value is being moved to the iframe HTML element were the report body is also "reparented".

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so this seems like the real fix: we want to set lang on the root of the application for accessibility, but to avoid confusing (since there's seemingly no real impact?), we should remove the leftover xml:lang from the reparented content document.

ixbrl-viewer only supports two application languages, so the user should only get lang="en" or lang="es" when looking at the DOM, so we probably need to explain that the user is looking in the wrong place to see the language of their report.

@austinmatherne-wk austinmatherne-wk linked an issue Dec 6, 2024 that may be closed by this pull request
@austinmatherne-wk austinmatherne-wk marked this pull request as draft December 6, 2024 20:59
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.

All Viewers Have en-US lang Attribute
5 participants