Coder Social home page Coder Social logo

Comments (3)

layershifter avatar layershifter commented on May 23, 2024

Hey, this issue was fixed in makeStyles sometime ago, microsoft/fluentui#20348. But read below ⬇️

It breaks with rules that flip in RTL, the simplest example is:

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

⬇️⬇️⬇️

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

.f1sheuf0:active,
:focus-within {
  padding-right: 10px;
}

P.S. You can dump all rules with:

console.log(
  [...document.querySelectorAll("[data-make-styles-bucket]")]
    .flatMap(el => [...el.sheet.cssRules].map(rule => rule.cssText))
    .join("\n")
);

P.P.S. We have tryout page to check generated CSS.

P.P.P.S. Thanks for reporting 🙏

from griffel.

layershifter avatar layershifter commented on May 23, 2024

The fix is needed in compileCSS.ts:

cssRule = `${classNameSelector}{${normalizedPseudo} ${cssDeclaration}};`;
if (rtlProperty) {
cssRule = `${cssRule}; ${rtlClassNameSelector}${normalizedPseudo} ${rtlCSSDeclaration};`;

It's not visible with template literals, but cssRule on 101 & 104 are different - there are missing curly brackets 🤦‍♂️

-cssRule = `${cssRule}; ${rtlClassNameSelector}${normalizedPseudo} ${rtlCSSDeclaration};`;
+cssRule = `${cssRule}; ${rtlClassNameSelector}{${normalizedPseudo} ${rtlCSSDeclaration}};`;

We also need to cover this with a unit test:

    it('handles complex nested selectors', () => {
      expect(resolveStyleRules({ '& > :first-child': { '& svg': { color: 'red' } } })).toMatchInlineSnapshot(`
        .fxfx2ih > :first-child svg {
          color: red;
        }
      `);
    });

+    it('handles comma separated selectors', () => {
+      expect(
+        resolveStyleRules({
+          ':active,:focus-within': {
+            paddingLeft: '10px',
+          },
+        }),
+      ).toMatchInlineSnapshot(`
+        .f14f5aie:active,
+        .f14f5aie:focus-within {
+          padding-left: 10px;
+        }
+        .f1sheuf0:active,
+        .f1sheuf0:focus-within {
+          padding-right: 10px;
+        }
+      `);
+    });

P.S. @spmonahan are you interested in contributing a fix? 😉

from griffel.

spmonahan avatar spmonahan commented on May 23, 2024

Didn't see an issue for this in the issue log but glad it was (mostly) fixed already!

Thanks for the debugging tips -- they will be very helpful! I've been following the work on Griffel DevTools and while looking into this issue was thinking, "can't wait for DevTools!".

Happy to contribute a fix. Should have time to work on it today.

from griffel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.