Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
88 stars 33 forks source link

Fixes missing styles on the Edit Subscription page when HPOS is enabled #521

Closed mattallan closed 12 months ago

mattallan commented 12 months ago

Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4563

Description

For stores with HPOS enabled, there are some styles missing on the Edit Subscription page which is noticeable when trying to update the subscription status:

image

This issue is caused by a missing dependency (wc-components) when registering our admin stylesheet.

Expected look: image

How to test this PR

[!WARNING]
Some plugins like WP Console seem to load this dependency, therefore while testing this PR, make sure every plugin is deactivated apart from WooCommerce and Woo Subscriptions.

  1. Enable HPOS on your store (WC > Settings > Advanced)
  2. View an Edit Subscription page (WC > Subscriptions > view a subscription)
  3. Click on the status drop-down menu
    1. On trunk you should notice no borders or on-hover styles
    2. On this branch the drop-down menu should be styled the same as the Edit Order page

Product impact

mattallan commented 12 months ago

Tests I've performed:

james-allan commented 12 months ago

Given this only affects the hpos screen, I did a diff on what stylesheet handles are loaded on the edit post subscription screen and what ones are missing on the HPOS edit screen. What I found is that these are the missing ones:

wc-components
wc-admin-layout
wc-customer-effort-score
wc-product-editor
wp-components
wc-experimental
wc-admin-app

So this PR does fix it by loading the wc-components which contains the missing wp admin variables. The other handles listed all looked like dependancies of the WC_ADMIN_APP ('wc-admin-app'). And so, after some digging what I've discovered is that these styles were automatically loaded on the wp-post edit screen because WC loads the 'wc-admin-app' scripts and the rest (including wc-components) are loaded as dependancies.

It doesn't load it on the HPOS screen because the edit subscription screen isn't considered one of WC's screens as defined by this PageController::is_admin_or_embed_page() function.