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

[docs–infra] Prevent displaying multiple ads #37696

Merged
merged 2 commits into from
Jun 26, 2023

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jun 24, 2023

Fix https://www.notion.so/mui-org/Trip-report-React-Summit-2023-18a3abdb83af4284b2d12f4deed18787?pvs=4#4554193ff13e46878e7f8b3e55db5d12, it was reported by a developer at React Summit, and something I experience every now and then too. Typically, it would look like this:

Screenshot 2023-06-25 at 01 56 33

You can be reproduced easily by opening https://mui.com/material-ui/getting-started/overview/ and running window._carbonads.init(). In real life, this happens because the script runs asynchronously, so if you have a slow connection, and quickly switch to a different page, you will see it.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work scope: docs-infra Specific to the docs-infra product labels Jun 24, 2023
Comment on lines 20 to 21
'& [id^=carbonads_]': {
display: 'none',
},
Copy link
Member Author

Choose a reason for hiding this comment

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

The fix, it works because of this logic in the ad script:

    var n = document.getElementsByClassName("carbon-wrap");
    var fdiv = document.createElement("div");
    fdiv.id = n.length > 0 ? "carbonads_" + n.length : "carbonads";
    fdiv.appendChild(el);

https://cdn.carbonads.com/carbon.js?serve=CKYIL27L&placement=material-uicom

@mui-bot
Copy link

mui-bot commented Jun 25, 2023

Netlify deploy preview

https://deploy-preview-37696--material-ui.netlify.app/

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 9192f6b

Comment on lines 19 to 21
'& [id^=carbonads_]': {
display: 'none',
},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'& [id^=carbonads_]': {
display: 'none',
},
'&>div': {
display: 'none',
},

Maybe more solid since it does not rely on how carbon manages its multiple ads

Copy link
Member

Choose a reason for hiding this comment

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

Could also be based on

&>div: { display: 'hidden' },
&>div:last-of-type: { ... }

Copy link
Member Author

Choose a reason for hiding this comment

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

I have changed the approach, this should be more resilient, inspired by your comment.

@oliviertassinari oliviertassinari enabled auto-merge (squash) June 26, 2023 11:40
@oliviertassinari oliviertassinari merged commit 067391d into mui:master Jun 26, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants