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: Multiple selectors and RTL flipping #110

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

spmonahan
Copy link
Contributor

Fixes #105

Current Behavior

When writing styles with multiple selectors and rules that will be flipped for RTL only the first selector is properly scoped to the generated class name.

import { makeStyles } from '@griffel/core';

export default makeStyles({
  root: {
    ':active,:focus-within': {
      paddingLeft: '10px'
    }
  },
});

Generates

.f14f5aie:active,
.f14f5aie:focus-within {
  padding-left: 10px;
}

.f1sheuf0:active,
// 💣💥`:focus-with` rule applies globally! 😱
:focus-within {
  padding-right: 10px;
}

New Behavior

import { makeStyles } from '@griffel/core';

export default makeStyles({
  root: {
    ':active,:focus-within': {
      paddingLeft: '10px'
    }
  },
});

Generates

.f14f5aie:active,
.f14f5aie:focus-within {
  padding-left: 10px;
}

.f1sheuf0:active,
// `:focus-within` is properly scoped 👍👍
.f1sheuf0:focus-within {
  padding-right: 10px;
}

Fixes an issue where only the first selector in a list of
comma-separated selectors would be scoped with the generated class name
when flipping styles for RTL.

See: microsoft#105
@spmonahan spmonahan requested a review from a team as a code owner April 26, 2022 17:51
@github-actions
Copy link

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
core
makeStyles + mergeClasses (runtime)
20.267 kB
7.549 kB
20.269 kB
7.549 kB
2 B
react
makeStyles + mergeClasses (runtime)
21.292 kB
7.982 kB
21.294 kB
7.98 kB
2 B
-2 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
core
makeStyles + mergeClasses (build time)
1.8 kB
861 B
react
makeStaticStyles (runtime)
8.247 kB
3.595 kB
react
makeStyles + mergeClasses (build time)
2.811 kB
1.275 kB
🤖 This report was generated against 3466692fd49ed689121bbd5638bb7072dcaa117a

@layershifter layershifter merged commit 7540e72 into microsoft:main Apr 27, 2022
@layershifter
Copy link
Member

Was fixed in @griffel/react@1.0.4.

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

Successfully merging this pull request may close these issues.

Multiple selectors are not properly scoped
4 participants