File tree Expand file tree Collapse file tree 6 files changed +16
-4
lines changed
ui-options/src/Options/Item Expand file tree Collapse file tree 6 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -912,6 +912,7 @@ export type OptionsItemTheme = {
912912 descriptionLineHeight : Typography [ 'lineHeight' ]
913913 descriptionPaddingStart : string | 0
914914 descriptionColor : Colors [ 'contrasts' ] [ 'grey4570' ]
915+ fontWeightSelected : Typography [ 'fontWeightNormal' ]
915916}
916917
917918export type OptionsSeparatorTheme = {
Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ class Item extends Component<OptionsItemProps> {
6161 role : 'listitem' ,
6262 voiceoverRoleBugWorkaround : false ,
6363 beforeLabelContentVAlign : 'center' ,
64- afterLabelContentVAlign : 'center'
64+ afterLabelContentVAlign : 'center' ,
65+ isSelected : false
6566 } as const
6667
6768 ref : Element | null = null
Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ type OptionsItemOwnProps = OptionsItemRenderProps & {
9494 * provides a reference to the underlying html root element
9595 */
9696 elementRef ?: ( element : Element | null ) => void
97+ /**
98+ * Whether or not this option is selected
99+ */
100+ isSelected ?: boolean
97101}
98102
99103type PropKeys = keyof OptionsItemOwnProps
@@ -133,7 +137,8 @@ const propTypes: PropValidators<PropKeys> = {
133137 href : PropTypes . string ,
134138 voiceoverRoleBugWorkaround : PropTypes . bool ,
135139 elementRef : PropTypes . func ,
136- children : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] )
140+ children : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
141+ isSelected : PropTypes . bool
137142}
138143
139144const allowedProps : AllowedPropKeys = [
@@ -149,7 +154,8 @@ const allowedProps: AllowedPropKeys = [
149154 'voiceoverRoleBugWorkaround' ,
150155 'href' ,
151156 'elementRef' ,
152- 'children'
157+ 'children' ,
158+ 'isSelected'
153159]
154160
155161export type { OptionsItemProps , OptionsItemStyle , OptionsItemRenderProps }
Original file line number Diff line number Diff line change @@ -112,7 +112,9 @@ const generateStyle = (
112112 display : 'block' ,
113113 fontSize : componentTheme . fontSize ,
114114 fontFamily : componentTheme . fontFamily ,
115- fontWeight : componentTheme . fontWeight ,
115+ fontWeight : props . isSelected
116+ ? componentTheme . fontWeightSelected
117+ : componentTheme . fontWeight ,
116118 lineHeight : componentTheme . lineHeight ,
117119 outline : 'none' ,
118120 position : 'relative' ,
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const generateComponentTheme = (theme: Theme): OptionsItemTheme => {
4545 fontFamily : typography ?. fontFamily ,
4646 fontWeight : typography ?. fontWeightNormal ,
4747 lineHeight : typography ?. lineHeightCondensed ,
48+ fontWeightSelected : typography ?. fontWeightNormal ,
4849
4950 color : colors ?. contrasts ?. grey125125 ,
5051 background : colors ?. contrasts ?. white1010 ,
Original file line number Diff line number Diff line change @@ -425,6 +425,7 @@ class Select extends Component<SelectProps> {
425425 // should option be treated as highlighted or selected
426426 if ( isSelected ) {
427427 optionProps . variant = 'selected'
428+ optionProps . isSelected = true
428429 } else if ( isHighlighted ) {
429430 optionProps . variant = 'highlighted'
430431 }
You can’t perform that action at this time.
0 commit comments