isSelected not working
See original GitHub issueI am trying to change the font weight to bold when option is being selected but isSelected
is not working.
Here is the codesandbox link
https://codesandbox.io/s/react-codesandboxer-example-9gpp4
I try to debug it with react-devtools
it’s not getting isFocused
isDisabled
and everything else but not isSelected
is not there.
Props
{
"value": {
"label": "Off Trade",
"value": "offTrade",
"id": 2,
"questionKey": 3
},
"options": [
"Object",
"Object",
"Object",
"Object"
],
"styles": {
"control": "control()",
"option": "option()",
"indicatorSeparator": "indicatorSeparator()",
"dropdownIndicator": "dropdownIndicator()"
},
"onChange": "fn()",
"inputValue": "",
"menuIsOpen": false,
"onInputChange": "fn()",
"onMenuClose": "fn()",
"onMenuOpen": "fn()",
"backspaceRemovesValue": true,
"blurInputOnSelect": false,
"captureMenuScroll": true,
"closeMenuOnSelect": true,
"closeMenuOnScroll": false,
"components": {},
"controlShouldRenderValue": true,
"escapeClearsValue": false,
"filterOption": "fn()",
"formatGroupLabel": "formatGroupLabel()",
"getOptionLabel": "getOptionLabel()",
"getOptionValue": "getOptionValue()",
"isDisabled": false,
"isLoading": false,
"isMulti": false,
"isRtl": false,
"isSearchable": true,
"isOptionDisabled": "isOptionDisabled()",
"loadingMessage": "loadingMessage()",
"maxMenuHeight": 300,
"minMenuHeight": 140,
"menuPlacement": "bottom",
"menuPosition": "absolute",
"menuShouldBlockScroll": false,
"menuShouldScrollIntoView": true,
"noOptionsMessage": "noOptionsMessage()",
"openMenuOnFocus": false,
"openMenuOnClick": true,
"pageSize": 5,
"placeholder": "Select...",
"screenReaderStatus": "screenReaderStatus()",
"tabIndex": "0",
"tabSelectsValue": true
}
State
{
"ariaLiveSelection": "option Off Trade, selected.",
"ariaLiveContext": "Select is focused ,type to refine list, press Down to open the menu, ",
"focusedValue": null,
"inputIsHidden": false,
"isFocused": false,
"menuOptions": {
"render": "Array[0]",
"focusable": "Array[0]"
},
"selectValue": [
{
"label": "Off Trade",
"value": "offTrade",
"id": 2,
"questionKey": 3
}
]
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
isSelected() method for checkbox always returns false
In my view, isSelected() returns true only if it is a default selection. It may not work when we select an element and...
Read more >isselected() method returning false always why?
First, I want to check whether checkbox is selected or not and then have to perform select action. But here ...
Read more >isSelected() method for checkbox always returns false on ...
Hello Everyone,In this video, i am going to discuss about the issue " isSelected () method for checkbox always returns false on selenium ......
Read more >isSelected | Apple Developer Documentation
A Boolean value that indicates whether the cell is selected.
Read more >The isSelected() method - Selenium WebDriver 3 Practical ...
The isSelected() method The isSelected method returns a boolean value if an element is selected on the web page and can be executed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suppose that
isSelected
property doesn’t exist inSelect
not marked asisMultiple
. So you can usestate.data === state.selectProps.value
in single choiceSelect
to apply different style based on state.Example:
@sarabs3 You can inspect the contents of
state
to see if there is anything useful for your use case.isSelected
exists in theoption
state but not in thecontrol
state, which I think makes, given that the options are what are actually selected.If you inspect the
state
in thecontrol
method you’ll see the propertyhasValue
. That should work for your use case: