Skip to content

Prevent duplicated script to hide admin bar in onboarding wizard #6877

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

Merged

Conversation

NikhilJoshua
Copy link
Contributor

Summary

Fixes #6643

Changes in PR prevent scripts to be printed multiple times on the page to hide the admin bar in the onboarding wizard.

image

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2022

CLA assistant check
All committers have signed the CLA.

@NikhilJoshua NikhilJoshua force-pushed the bug/6643-prevent-duplicate-scripts branch from c620b1a to c86439b Compare February 4, 2022 10:58
Copy link
Collaborator

@delawski delawski left a comment

Choose a reason for hiding this comment

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

Thanks for your work, @NikhilJoshua!

The code looks good to me. I left one minor comment about unit tests.

Comment on lines +197 to +198
add_action( 'wp_head', 'amp_remove_admin_bar_in_phone_preview' );
add_action( 'amp_post_template_head', 'amp_remove_admin_bar_in_phone_preview' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we maybe add a unit test to confirm that those two hooks are added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@delawski There's no test case for amp_init() function so I didn't add it. Let me know your thoughts on it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll defer to @westonruter who's now free to do the final review.

Co-authored-by: Piotr Delawski <[email protected]>
@delawski delawski requested a review from westonruter February 8, 2022 16:21
@delawski delawski added this to the v2.2.2 milestone Feb 8, 2022
@delawski delawski added the Bug Something isn't working label Feb 8, 2022
Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

The E2E test is a nice touch 👍

Comment on lines +25 to +28
// Checks for admin bar in iframe phone preview.
const iframeElement = await page.$( 'iframe[name="amp-wizard-completion-preview"]' );
const previewFrame = await iframeElement.contentFrame();
await expect( previewFrame ).not.toMatchElement( '#wpadminbar' );
Copy link
Member

Choose a reason for hiding this comment

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

Good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you :)

@westonruter westonruter merged commit 95c009a into ampproject:develop Feb 8, 2022
westonruter added a commit that referenced this pull request Feb 8, 2022
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicated script printed to hide admin bar in onboarding wizard
4 participants