fix(vue-vanilla): fix type coercion for Enum and OneOfEnum controls#3
Conversation
This commit fixes an issue where selecting an integer value in the `EnumControlRenderer` or `EnumOneOfControlRenderer` would incorrectly write a stringified version of the integer to the JSONForms data state, causing validation errors. The components were updated to look up the correct value from `options` using `selectedIndex - 1` (accounting for the hardcoded empty option at index 0) instead of relying on `target.value`. Additional tests were added to explicitly verify this behavior with an `integer` based schema.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Fixed type coercion in
vue-vanillaenum and oneOf dropdowns.Previously,
target.valuewas used to grab the selected value from<select>inputs inEnumControlRendererandEnumOneOfControlRenderer. This would implicitly coerce all values into strings, breaking schemas that demanded strictly typed values (e.g.integerschemas).This changes both controls to look up the typed value using
input.control.value.options[target.selectedIndex - 1].value, preserving the correct original type (e.g. number, boolean, etc.). Tests were expanded to explicitly ensure that numbers remain correctly typed.PR created automatically by Jules for task 4822673399870400796 started by @darius-lesch