-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
FIX: Add order to outputted stylesheet link tags #13735
Conversation
This looks good to me but could it possibly break existing themes where they depended on the previous order? I agree this order is better, for the record. I just want to figure out if any forums will be affected negatively. |
Yes, it can potentially break existing sites. We currently don't have a load order, though, so this would have caused issues sooner or later anyway... I will test this on a few sites with many themes and components before merging. Also, the main risk here are sites that have styles in a component that are supposed to override styles in the parent theme. |
Thanks I think it's better to have an order than not, but we should be aware of the risk and have a plan of action when merging. |
- remote components (a to z) - remote parent theme (if applicable) - local components (a to z) - local parent theme (if applicable)
childA = hrefs.select { |href| href[:theme_id] == child_theme.id }.first | ||
childZ = hrefs.select { |href| href[:theme_id] == z_child_theme.id }.first | ||
childR = hrefs.select { |href| href[:theme_id] == child_remote.id }.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're mixing camelCase and snake_case for the variables in this spec. Usually we default to snake_case for variable names in Ruby.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor code style comments but the PR looks good to me otherwise. Regarding how we would deploy this, I recommend just putting the sorting behind a hidden site setting first and then roll it out slowly across our hosting.
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
Theme and component stylesheets have so far been loaded without a specified order. This causes issues. Especially on sites with multiple themes and multiple components, styles from components would sometimes take precedence over the base theme and sometimes it would be the other way around.
This PR orders the theme stylesheets thusly:
Note that stylesheet ordering is not yet enabled by default, for now this behaviour is behind a hidden site setting:
order_stylesheets
.To use this, do the following in the Rails console:
This PR also removes an extra layer of caching. We cache the full array of stylesheets for a specific target, and we also cached each stylesheet path, which is redundant.