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

fix(embedded-sdk): add accessible title to iframe #27017

Merged
merged 6 commits into from
Jun 4, 2024

Conversation

bhaugeea
Copy link
Contributor

@bhaugeea bhaugeea commented Feb 5, 2024

SUMMARY

Screen reader users may rely on the (missing) title attribute to know that the iframe is where the dashboard content is. This PR adds a title to the iframe with the generic value "Embedded Dashboard".

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue: Fixes Embedded dashboard iframe missing title (accessibility) #27016
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@@ -154,6 +154,7 @@ export async function embedDashboard({
});

iframe.src = `${supersetDomain}/embedded/${id}${dashboardConfig}${filterConfigUrlParams}`;
iframe.title = 'Embedded Dashboard';
Copy link
Member

Choose a reason for hiding this comment

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

This works in a pinch, but does the dashboard config (or something else) happen to provide the actual title of the dashboard? That would be the ideal thing to put here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No not that I'm aware of, and the SDK doesn't fetch it either. It looks like the SDK doesn't load anything from Superset API at all — just gets a token using the opaque function it's given, and passes it to the iframe content.

Copy link
Member

@mistercrunch mistercrunch Feb 6, 2024

Choose a reason for hiding this comment

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

It seems the sdk should expose the option to set this as maybe an iframeTitle property of the dashboardConfig object (?), and fall back on some default like this one "Embedded Dashboard". Note that for extra points you could i18n that string as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it to the config. Didn't provide a fallback for now because I'd probably butcher the i18n. Would a fallback be required for this, or okay without?

Copy link
Member

@mistercrunch mistercrunch Feb 6, 2024

Choose a reason for hiding this comment

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

Ok without AFAIC, the i18n is easy though, just FYI ->

import { t } from '@superset-ui/core';

const translatableString = t("Embedded Dashboard");

What happens then is the i18n framework scans through the code base and inventorize all those strings on the backend and frontend, where other people can then translate then in various languages.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@rusackas
Copy link
Member

rusackas commented Feb 6, 2024

Thanks for following up... running CI 🤞

@bhaugeea
Copy link
Contributor Author

bhaugeea commented Feb 6, 2024

I believe the whole ui/core package would need to be added as a dependency here. I haven't tried to open the can of worms of actually running this repo so not confident in being able to get that working.

@@ -77,6 +80,7 @@ export async function embedDashboard({
id,
supersetDomain,
mountPoint,
iframeTitle = t("Embedded Dashboard"),
Copy link
Member

Choose a reason for hiding this comment

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

Hey this look like a public interface, so this new [optional] param should be the last one in the function call for backwards compatibility, otherwise we'l have off-by-one param matching on the function call!

@@ -154,6 +158,9 @@ export async function embedDashboard({
});

iframe.src = `${supersetDomain}/embedded/${id}${dashboardConfig}${filterConfigUrlParams}`;
if(iframeTitle) {
Copy link
Member

Choose a reason for hiding this comment

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

I think given the default value set in the function header, this will always have a value, so no if required. Actually I think if someone actually wanted an empty string and pass iframeTitle = '' or iframeTitle = null in the function call, it would prevent them from overriding the Embedded Dashboard default :/

@mistercrunch
Copy link
Member

mistercrunch commented Feb 7, 2024

I believe the whole ui/core package would need to be added as a dependency here. I haven't tried to open the can of worms of actually running this repo so not confident in being able to get that working.

Oh you're right about that! Let's actually not do this then. Not worth adding the dependency for the sake of a i18n that one string!

@rusackas
Copy link
Member

rusackas commented Jun 3, 2024

@mistercrunch @bhaugeea Curious if you see a way forward with this, so we can close out the PR and Issue. If there's no intent to rebase this in the near future and get it across the finish line, I'll convert this to a Draft, and the issue may closed as stale in time.

Addressing my comments
@mistercrunch
Copy link
Member

@rusackas I just made the changes I suggested and removed superset-ui/core dependency that was reference, but wasn't added as a dependancy of the sdk since it could have implications.

@rusackas rusackas merged commit 1a52c6a into apache:master Jun 4, 2024
31 checks passed
@nikola-arcadis
Copy link

I don't see this change is published on npmjs registry with version 0.1.0-alpha.11. How can we get the new package with this change?

@rusackas
Copy link
Member

Sorry... we need to update a bunch of npm packages. We'll try to get that effort underway soon.

@mistercrunch
Copy link
Member

@rusackas is the process to do that documented someplace? Oh nevermind found an example PR -> https://github.com/apache/superset/pull/13593/files

@rusackas
Copy link
Member

rusackas commented Jun 28, 2024

That brings in the newly published ones, but here are the instructions (the most current I'm aware of) to actually publish the modules to NPM:

https://github.com/apache/superset/pull/23730/files

This should be made part of the release process, but for now, I have it on my task list to go back and try it on some of the voted-in release branches/SHAs.

eschutho pushed a commit that referenced this pull request Jul 24, 2024
Co-authored-by: Maxime Beauchemin <maximebeauchemin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embedded dashboard iframe missing title (accessibility)
4 participants