Skip to content

Conversation

@jeherve
Copy link
Member

@jeherve jeherve commented Oct 8, 2019

Follow up from #13450

Changes proposed in this Pull Request:

  • In some cases, admin-bar styles may be dequeued (like when the Masterbar module is active). Let's consequently not rely on them to be there.

cc @westonruter

Testing instructions:

  • Before to apply this patch, enable both Notifications and the Masterbar module.
  • Notice the broken layout.
  • Apply patch.
  • Notice that both the Masterbar and the Notifications work well.

Proposed changelog entry for your changes:

  • None

Follow up from #13450

In some cases, admin-bar styles may be dequeued (like when the Masterbar module is active).
@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Notifications [Status] Needs Review This PR is ready for review. [Pri] BLOCKER labels Oct 8, 2019
@jeherve jeherve added this to the 7.9 milestone Oct 8, 2019
@jeherve jeherve requested a review from a team October 8, 2019 14:03
@jeherve jeherve self-assigned this Oct 8, 2019
@jetpackbot
Copy link
Collaborator

jetpackbot commented Oct 8, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: November 5, 2019.
Scheduled code freeze: October 29, 2019

Generated by 🚫 dangerJS against ed1f3e6

@westonruter
Copy link
Contributor

@jeherve If the stylesheet is not marked as having an admin-bar dependency, then you'll need to manually mark it as being part of AMP dev mode, as can be seen with the script_loader_tag filter for scripts. So something like this:

if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
	add_filter(
		'style_loader_tag',
		function ( $tag, $handle ) {
			if ( in_array( $handle, [ 'wpcom-notes-admin-bar', 'noticons' ], true ) ) {
				$tag = preg_replace( '/(?<=<link)(?=\s|>)/i', ' data-ampdevmode', $tag );
			}
			return $tag;
		},
		10,
		2
	);
}

@jeherve
Copy link
Member Author

jeherve commented Oct 8, 2019

@westonruter That makes sense, thank you. How about a different approach, like this?
ed1f3e6

@westonruter
Copy link
Contributor

I don't know much about the Masterbar, but the change should work. Nevertheless, since wpcom-notes-admin-bar has admin-bar as a dependency, would wp_dequeue_style() even do anything since it isn't being directly enqueued to begin with?

@kraftbj
Copy link
Contributor

kraftbj commented Oct 8, 2019

I'm marking this as approved since it does resolve the original issue.

When using AMP in canonical mode, the traditional admin bar is on the front end -- is this expected? No issues or errors, but different behavior with AMP on vs off.

Marking as Need Author Reply as I'm deferring to @jeherve's opinion, but fine to merge to me to help Atomic and we can fix up if the AMP issue is an issue later.

@kraftbj kraftbj added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Oct 8, 2019
@kristarella
Copy link

When using AMP in canonical mode, the traditional admin bar is on the front end -- is this expected? No issues or errors, but different behavior with AMP on vs off.

I noticed this when testing AMP on the weekend. Does Jetpack influence this? There used to be an option in the AMP plugin whether or not to display the admin bar, but that option is no longer there. IMO it would be better not to display the admin bar because it is adding extra CSS to the page that might affect the CSS treeshake (like bumping out other CSS for being over the 50kb limit).

@westonruter
Copy link
Contributor

As of AMP v1.3 the admin bar no longer counts against the 50KB limit. This is why there is no longer an option to disable the admin bar on AMP pages.

@kraftbj
Copy link
Contributor

kraftbj commented Oct 9, 2019

To clarify, my curiosity was more that the traditional admin bar was present on an AMP page and not the wpcom masterbar. Between the options of the traditional admin bar or no admin bar at all, I'd like to see the traditional admin bar given AMP canonical would be the primary post view experience.

@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Oct 9, 2019
@jeherve
Copy link
Member Author

jeherve commented Oct 9, 2019

since wpcom-notes-admin-bar has admin-bar as a dependency, would wp_dequeue_style() even do anything since it isn't being directly enqueued to begin with?

It does, yes. In practice, you end up with the admin bar not being loaded at all:
image

When using AMP in canonical mode, the traditional admin bar is on the front end -- is this expected

I'd say yes. As you point out the traditional admin bar seems like a better fit there.

@kraftbj kraftbj added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Oct 9, 2019
@kraftbj kraftbj merged commit cd17208 into master Oct 9, 2019
@kraftbj kraftbj deleted the fix/masterbar-layout branch October 9, 2019 14:52
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Notifications [Pri] BLOCKER [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants