fix: Radio group options not accessible (#31382)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Improved accessibility by adjusting the focus behavior of radio
buttons.
- Enhanced feature flag handling for more granular control over new
features.

- **Refactor**
- Optimized feature flag checks for better performance and readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro-2.local>
This commit is contained in:
Pawan Kumar 2024-03-01 17:45:54 +05:30 committed by GitHub
parent a0e87c3152
commit 90a53cb438
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,8 @@ export function defaultOptionValidation(
props: any,
_: any,
): ValidationResponse {
let { options } = props;
//Checks if the value is not of object type in {{}}
if (_.isObject(value)) {
return {
@ -33,6 +35,36 @@ export function defaultOptionValidation(
};
}
if (!Array.isArray(options) && typeof options === "string") {
try {
const parsedOptions = JSON.parse(options);
if (Array.isArray(parsedOptions)) {
options = parsedOptions;
} else {
options = [];
}
} catch (e) {
options = [];
}
}
// @ts-expect-error type mismatch
const valueIndex = _.findIndex(options, (option) => option.value === value);
if (valueIndex === -1) {
return {
isValid: false,
parsed: value,
messages: [
{
name: "ValidationError",
message: `Default value is missing in options. Please update the value.`,
},
],
};
}
return {
isValid: true,
parsed: value,