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

fix(MultiSelect): Apply a temporary fix for Vanilla includes in MultiSelect component #1052

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

bartaz
Copy link
Member

@bartaz bartaz commented Mar 14, 2024

Done

  • Updates Vanilla to 4.9.0
  • Removes problematic @includes (vf-base and vf-b-forms) and@extend uses from MultiSelect.scss and replaces them with copies of relevant parts of Vanilla.

This is a temporary solution until we find better ways to reuse bigger parts of Vanilla styling. @extend usage by itself is not huge issue, but it does silently create a duplicate of Vanilla styling.
Bigger problem was including vf-base and vf-lists (which contain required placeholders to extend) as they duplicate big chunks of Vanilla styling creating source order conflicts of old and new styles and breaking the styling of some other components.

QA steps

Fixes

Fixes: #1041

@webteam-app
Copy link

Demo starting at https://react-components-1052.demos.haus

@bartaz bartaz changed the title WIP: Fix multiselect scss fix(MultiSelect): Apply a temporary fix for Vanilla includes in MultiSelect component Mar 14, 2024
@bartaz
Copy link
Member Author

bartaz commented Mar 14, 2024

Percy: https://percy.io/bb49709b/react-components/builds/33166994/

The expected changes are visible (Slider is fixed).

There are a lot of unrelated changes caused by Vanilla upgrade that includes new theming and new icon colours, etc.

There is also some weird behaviour in Percy that it shows new input border as lighter than before, which is weird because when checked in the browser it doesn't look lighter than before.

image

I'm ignoring it for now, assuming it's some Percy/Storybook glitch, but would be good to undestand the cause and if we can do anything about it, to avoid false negatives in future.

@@ -1,7 +1,4 @@
@import "~vanilla-framework/scss/settings";
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing unnecessary individual imports.
It's all included in full Vanilla import and there is no downside to import it all (no CSS produced until anything is included).


$dropdown-max-height: 20rem;

// XXX: Temporarly we are duplicating some of the placeholders defined in Vanilla
Copy link
Member Author

Choose a reason for hiding this comment

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

In longer term we should either upstream this component to Vanilla or refactor some bits of Vanilla to be able to extend these parts that are needed here, without the need to include the whole base or list styles, because duplication of base form styles was the cause of the issue (broken slider styles overriden by duplicated input styles).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest we link to a new issue in react-components where we explain this in detail (and move this comment there).

Copy link
Member Author

Choose a reason for hiding this comment

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

It felt more fitting on Vanilla itself: canonical/vanilla-framework#5030

@bartaz bartaz marked this pull request as ready for review March 14, 2024 16:20

$dropdown-max-height: 20rem;

// XXX: Temporarly we are duplicating some of the placeholders defined in Vanilla
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest we link to a new issue in react-components where we explain this in detail (and move this comment there).

src/components/MultiSelect/MultiSelect.scss Show resolved Hide resolved
@@ -1,11 +1,15 @@
@use "sass:map";
@import "vanilla-framework";
@include vf-base;
@include vf-p-lists;
@include vf-b-placeholders; // Vanilla base placeholders to extend from
Copy link
Member Author

Choose a reason for hiding this comment

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

This is safe to include, as it only contains placeholders, not any actual Vanilla styling.

// Scope Vanilla form includes to multi select component only
// to avoid overriding any Vanilla base styles
// XXX: This is a workaround for https://github.com/canonical/vanilla-framework/issues/5030
@include vf-b-forms;
Copy link
Member Author

Choose a reason for hiding this comment

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

As for now vf-b-forms contains both placeholders that we want to extend here and default form styling (that we don't want to duplicate). So to avoid overriding default Vanilla we need to scope it within the component.

Copy link
Member Author

Choose a reason for hiding this comment

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

@petermakowski I think I found a cleaner workaround for extending Vanilla styles in components.

@petermakowski petermakowski merged commit 7e8a1c1 into main Mar 19, 2024
7 checks passed
Copy link

🎉 This PR is included in version 0.50.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slider input field has wrong width
3 participants