Skip to content

MergeStyles $ Selector Not Working When Applied to a Component with a Root Style Set #4138

@oengusmacinog-zz

Description

@oengusmacinog-zz

Bug Report

  • Package version(s): v5.56

Priorities and help requested (not applicable if asking question):

Are you willing to submit a PR to fix? Yes

Requested priority: Normal

Products/sites affected: N/A

Describe the issue:

When applying style sets in a component (e.g. Nav) to a sub-component (e.g. ActionButton) which already has a root style set you will run into an issue using a $ selector on the item like:

'$link:hover &': {
     color: blue
}

The conflict happens because it's root style set would normally be applied to a class like root-###, but being applied as link inside the Nav component applies that style set to link-### class name. Styles applied using this $ selector syntax do not render out.

Actual behavior:

chevronButton: { // applied to html <button> tag
     position: 'relative'
},
compositeLink: { // applied to ActionButton Fabric Component
     display: 'block'
},
link: {
     display: 'inline',
     selectors: {
          '$chevronButton:hover &': {  // Renders styles correctly
               color: '#009'
          },
          '$compositeLink:hover &': {  // Never renders styles
               color: '#009'
          }
     }
}

Expected behavior:

Style renders to page.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions