question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin style merge issues: Rules appear to be getting overwritten by 2nd class not merged into rules from 1st class

See original GitHub issue

Demo of a problem I am seeing.

I created a plugin for sidebar styling it is incomplete but I was seeing something that surprised me. I am not certain this is a bug, but it’s not doing what I expected, though possibly my expectations may be faulty.

Styles from two classes appear to be getting over written for a given style rule path “> *” rather than merged, so the 2nd classes styles for that path are replace the rules from the first class styles.

https://codesandbox.io/s/cra-tailwind-emotion-starter-demo-possible-style-not-merging-bug-twinmacro-tf4vk

I found if i use the rule .with-sidebar__rightAlternate the styles merge but its kind of cheating by adding > *:first-child so it doesn’t match the rule > * used in .with-sidebar.

The plugin creating the styles.

function sidebarPlugin({ addUtilities }) {
  addUtilities({
    [`.with-sidebar > *`]: {
      display: 'flex',
      flexWrap: 'wrap'
    }
  })
  addUtilities({
    [`.with-sidebar__right > *`]: {
      flexDirection: 'row-reverse'
    }
  })
  addUtilities({
    [`.with-sidebar > * > *`]: {
      flexGrow: 1
    }
  })
  // last-child is always not-sidebar
  addUtilities({
    [`.with-sidebar > * > *:last-child`]: {
      flexBasis: 0,
      flexGrow: 999,
      minWidth: `calc(50%)`
    }

  addUtilities({
    [`.with-sidebar__rightAlternate > *:first-child`]: {
      flexDirection: 'row-reverse'
    }
  })
  })
}

Styles rules from different classes not merging.

twwith-sidebar with-sidebar__right styles This shows style “> *” has lost the flex and wrap settings from with-sidebar. Which ever class name is last overwrites the first, it does not merge.

{
  "> *": {
    "flex-direction": "row-reverse"
  },
  "> * > *": {
    "flex-grow": "1"
  },
  "> * > *:last-child": {
    "flex-basis": "0",
    "flex-grow": "999",
    "min-width": "calc(50%)"
  }
}

twwith-sidebar__right with-sidebar styles This shows style “> *” has lost the styles from with-sidebar__right. Which ever class name is last overwrites the first, it does not merge.

{
  "> *": {
    "display": "flex",
    "flex-wrap": "wrap"
  },
  "> * > *": {
    "flex-grow": "1"
  },
  "> * > *:last-child": {
    "flex-basis": "0",
    "flex-grow": "999",
    "min-width": "calc(50%)"
  }
}

twwith-sidebar styles

{
  "> *": {
    "display": "flex",
    "flex-wrap": "wrap"
  },
  "> * > *": {
    "flex-grow": "1"
  },
  "> * > *:last-child": {
    "flex-basis": "0",
    "flex-grow": "999",
    "min-width": "calc(50%)"
  }
}

twwith-sidebar__right styles

{
  "> *": {
    "flex-direction": "row-reverse"
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rluitencommented, May 15, 2020

Awesome work thank you.

0reactions
ben-rogersoncommented, May 13, 2020

This should be fixed in v1.0.0 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage manifest files - Android Developers
This page describes how manifest merging works and how you can apply merge preferences to resolve merge conflicts.
Read more >
Documentation - Declaration Merging - TypeScript
Disallowed Merges​​ Not all merges are allowed in TypeScript. Currently, classes can not merge with other classes or with variables. For information on...
Read more >
Git stash pop- needs merge, unable to refresh index
First, check git status . As the OP mentions,. The actual issue was an unresolved merge conflict from the merge, NOT that the...
Read more >
Merge (Data Management)—ArcGIS Pro | Documentation
Use this tool to combine datasets from multiple sources into a new, single output dataset. All input feature classes must be of the...
Read more >
Merge requests API - GitLab Docs
The state parameter can be used to get only merge requests with a given state ( opened , closed , locked , or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found