cssinjs / cssinjs/jss

Wrong order for generated nested styles

Open
#1,657 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

Description

__Expected behavior:__
Order of generated styles is same as in jss styles

__Describe the bug:__
In some cases for nested styles order of generated styles is REVERSED

__Reproduction:__
Styles:

```
export const test = createUseStyles({
test: {
'& $first': {
//
'&:hover': { color: 'white' },
},

'& $second': {
//
'&:hover': { color: 'red' },
},
},

first: { color: 'red' },

second: { color: 'blue' },
});
```

Generated styles:
```

.test-0-2-931 .second-0-2-933:hover {
color: red;
}
.test-0-2-931 .first-0-2-932:hover {
color: white;
}
.first-0-2-932 {
color: red;
}
.second-0-2-933 {
color: blue;
}

```

__Versions (please complete the following information):__
- jss: 10.10.0
- react-jss: 10.10.0
- Browser [e.g. chrome, safari]: Chrome 121.0.6167.140 (Last)
- OS [e.g. Windows, macOS]: Windows 10

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied nested-style example with jss and react-jss 10.10.0 in Chrome, then inspect how the generated rules are ordered. Done means the generated nested hover rules preserve the order of the corresponding JSS styles instead of being reversed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.