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

Fixed: Issue 25818 Preview Area Weird Boarder Accessibility Addon #28844

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

RuxueJ
Copy link

@RuxueJ RuxueJ commented Aug 9, 2024

Closes #25818

What I did

We fixed the border issue with the blur filter by:

  1. Use useEffect hook to dynamically apply the filters to the content inside the iframe instead of iframe itself
  2. Inject the customized SVG filters to iframe so that the contents in iframe have access to all the filters.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

We tested every filter with the accessibility addon.

  1. Install accessibility addon a11y following Storybook instructions
  2. Cd to sandbox/react-vite-default-ts folder, and run command yarn build-storybook and yarn storybook
  3. Open Storybook in your browser.
  4. Open accessibility tab and click on filters .
2

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 78.7 MB 78.7 MB 0 B 2.45 0%
initSize 147 MB 147 MB 468 B 2.28 0%
diffSize 68.3 MB 68.3 MB 468 B 1.94 0%
buildSize 6.79 MB 6.79 MB 0 B 0.91 0%
buildSbAddonsSize 1.5 MB 1.5 MB 0 B -1 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.83 MB 1.83 MB 0 B 1 0%
buildSbPreviewSize 270 kB 270 kB 0 B -1 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.8 MB 3.8 MB 0 B 0.94 0%
buildPreviewSize 2.99 MB 2.99 MB 0 B -1 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 14.3s 13.5s -820ms 0.34 -6.1%
generateTime 21.1s 21.9s 784ms 0.05 3.6%
initTime 12.7s 13.3s 662ms -0.31 5%
buildTime 8.1s 8.3s 182ms -0.36 2.2%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.5s 5.8s 290ms -0.7 4.9%
devManagerResponsive 3.7s 4s 261ms -0.42 6.5%
devManagerHeaderVisible 547ms 556ms 9ms -0.54 1.6%
devManagerIndexVisible 577ms 587ms 10ms -0.54 1.7%
devStoryVisibleUncached 948ms 671ms -277ms -1.41 🔰-41.3%
devStoryVisible 578ms 588ms 10ms -0.55 1.7%
devAutodocsVisible 451ms 507ms 56ms -0.31 11%
devMDXVisible 443ms 491ms 48ms -0.55 9.8%
buildManagerHeaderVisible 461ms 481ms 20ms -0.85 4.2%
buildManagerIndexVisible 545ms 517ms -28ms -0.64 -5.4%
buildStoryVisible 545ms 518ms -27ms -1.05 -5.2%
buildAutodocsVisible 448ms 442ms -6ms -0.77 -1.4%
buildMDXVisible 479ms 414ms -65ms -1.01 -15.7%

Greptile Summary

The changes in VisionSimulator.tsx resolve the issue of applying filters to iframe content instead of the iframe itself, ensuring proper filter application without affecting the iframe's border.

  • Dynamic Filter Application: Utilized useEffect to apply filters to iframe content dynamically.
  • SVG Filter Injection: Introduced injectFilters function to inject customized SVG filters into the iframe.
  • Component Removal: Removed the Hidden styled component and the Global component that applied filters directly to the iframe.
  • Filter Consistency: Ensured filters are applied correctly to iframe content without affecting the iframe's border.

Thorough testing is recommended to ensure all filters work as expected.

saadmalik96 and others added 2 commits August 2, 2024 10:36
Changed how accessibility filters are applied within Storybook. The filters are no longer applied to the iframe rather we apply filters to iframe contents by targeting the 'storybook-root' div within the iframe. This fixes the weird border bug caused by the blur filter and will also prevent any future unwanted interactions of accessibility filters with the iframe's css.

Co-Authored-By: RuxueJ <[email protected]>
Co-Authored-By: allybc1124 <[email protected]>
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Member

@ndelangen ndelangen left a comment

Choose a reason for hiding this comment

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

I really appreciate the time and effort put into this PR.

Visually this solves the problem it aims to fix, however it doesn't work in all use-cases, but I understand you didn't know about all.

If you have the time and energy to change this PR somewhat significantly, I'd like to ask you to change it.

Main take-away is that accessing the iframe's contentDocument is something we avoid, due to a feature called storybook composition (1 storybook embedding others).


I'm thinking perhaps we upgrade the addon to work more like the background addon does, where a global is used for state, which can be read in the preview as well (in a decorator).

WDYT?


useEffect(() => {
const iframe = document.getElementById(iframeId) as HTMLIFrameElement;
if (iframe && iframe.contentDocument) {
Copy link
Member

Choose a reason for hiding this comment

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

Accessing the contentDocument will only work if the iframe is on the same origin, which is not always the case.

We should encapsulate this behavior in a storybook decorator instead, similar to how the backgrounds addon works.

Syncing state via a global.

export const withBackgroundAndGrid = (

Choose a reason for hiding this comment

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

Hi @ndelangen thank you for taking a look at our PR and for leaving such a detailed response.

In the issue page, we left a simpler alternate solution which is to remove the seemingly unnecessary boxShadow css in iframe.tsx. The boxShadow has no visual effect on preview window at the moment and since the blur filter only causes the bug with this boxShadow, this would resolve the weird border bug and then upgrading the addon can be a separate issue? You can find this here:

boxShadow: '0 0 100px 100vw rgba(0,0,0,0.5)',

If you still prefer upgrading the addon for this particular issue, could you roughly outline the steps needed and your expectation? Like would the a11y addon need to be structured similarly to the background addon? We would like to understand this approach a bit better before diving right in.

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.

[Bug]: preview area has weird border with blurred vision filter
4 participants