Improve Flutter Web accessibility: update flt meta viewport tag to align with WCAG 2 guidelines#182047
Improve Flutter Web accessibility: update flt meta viewport tag to align with WCAG 2 guidelines#182047jlemanski1 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the viewport meta tag for Flutter Web applications to improve accessibility. Specifically, it removes the user-scalable=no attribute and increases maximum-scale from 1.0 to 5.0, aligning with WCAG guidelines that recommend allowing users to zoom. The corresponding test in window_test.dart has also been updated to reflect these changes.
|
Thanks for looking into this! I haven't tested this patch yet, but I'm curious what happens when you scale a Flutter app? Does it continue to work correctly? What does the browser do when the user scales the page, does it change the |
|
Hi @mdebbar, No worries! I did some basic testing with a Flutter web app that measured pointer events, had text, sliders, and some gesture detection and I found no regressions on desktop web or mobile web when compared to the latest stable Flutter release. Running the web app on my local Flutter Engine from this branch, the The browser scales as expected in on either this branch or the latest stable release, the main difference is that automated accessibility checks don't flag this version as it doesn't have the |
|
Confirmed locally by deploying both branches to Firebase:
The audit fix works as advertised: Lighthouse / ACT b4f0c3 passes, Cmd +/- and devicePixelRatio behave the same as on stable, matching @mdebbar's question above. One thing worth flagging though: this PR doesn't actually unblock pinch-zoom on mobile. _setHostStyles at |
Thank you for validating @flutter-zl The initial issue I had opened, 97305 was for the audit only, but was renamed by someone on the Flutter team in 2022. For context on the initial issue, the primary goal at the time was to resolve the audit as that web app had implemented pinch to zoom at the widget level. The web app was for a large American university that required a certain level of accessibility to receive approval/funding, and unfortunately that viewport tag was the piece that preventing that audit from passing. Personally, I would like to see this change brought into Flutter so that a fresh flutter web app (with the I'm happy to update the PR to tag it to only 122127, the audit issue if that helps to get this merged. Just let me know! Thanks |
Agreed the audit fix is worth landing on its own. LGTM. |
chunhtai
left a comment
There was a problem hiding this comment.
I am not sure this really brings value besides makes muted the warning in lighthouse or audit tool. For those who is chasing VPAT or WCAG compliance, they would still need to make sure the pinch zoom works before checking off the checkbox
|
Hi @chunhtai, From my perspective, the value-add for this change is the resolved warning in lighthouse. It doesn't implement pinch to zoom Flutter web-wide, but if you implement it at the application-level, the viewport tag will no longer plague you in lighthouse scores. Optics-wise, it also vastly improves the lighthouse accessibility score on a fresh flutter web project. When teams are evaluating Flutter web, it can be disconcerting to read the accessibility page in the docs, then spin up a fresh project and see warnings. |
chunhtai
left a comment
There was a problem hiding this comment.
yeah.. i guess sooner or later we need to add the attr. LGTM then
This PR updates the parameters in the flutter viewport meta tag to align with the WCAG 2 rule concerning restricting user scaling and increases the light house accessibility score of a brand new Flutter Web project. Using the
hello_worldexample project, the lighthouse accessibility score jumps from 87 to 95.The reason for this change is the failure of Flutter Web in automated accessibility check the values of the
user-scalableandmaximum-scaleproperties. When evaluating Flutter Web against other frameworks, this restriction can be a blocker for many organizations.One workaround for this issue is to use the
CustomElementEmbeddingStrategyand set up the viewport tag and container element yourself, though this is not a welcoming workflow for developers that are new to Flutter Web.Fixes:
Pre-launch Checklist
///).