aws-amplify / aws-amplify/amplify-studio
UI Library: Duplicated onChange() of switch field
- Dominant language
- No language data
- Stars
- 135
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-adminui/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-adminui/blob/main/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
XXX
### Region
ap-southeast-2
### Environment name
staging
### Figma File Version (if applicable)
_No response_
### Amplify CLI Version
12.3.0
### If applicable, what version of Node.js are you using?
_No response_
### What operating system are you using?
Mac
### Browser type?
Chrome
### Describe the bug
Use UI Library to add an `onChange` prop for a switch field. The generated code has duplicated `onChange`.
### Expected behavior
Generate only one `onChange`, combine the new `onChange` with the default `onChange`.
### Reproduction steps
1. Create a Figma component with Switch filed component.
2. Configure the component in UI Library.
3. Add a `onChange` prop.

4. Amplify pull.
5. Check the code.
```
{
switchFieldOnChange();
}}
onChange={() => setSwitchFieldIsChecked(!switchFieldIsChecked)}
{...getOverrideProps(overrides, "SwitchField")}
>
```
### Project Identifier
_No response_
### Additional information
_No response_
Contributor guide
Research direction
Reproduce the issue by configuring a Figma Switch field with an onChange prop and running Amplify pull. Inspect the generated SwitchField JSX and identify how the default and configured handlers are emitted. Done means the generated component has one onChange that combines both behaviors; add or update regression coverage if the project provides it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100