amplify-studio icon indicating copy to clipboard operation
amplify-studio copied to clipboard

UI Library: Duplicated onChange() of switch field

Open lwang-79 opened this issue 1 year ago • 1 comments

Before opening, please confirm:

  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting 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. image
  4. Amplify pull.
  5. Check the code.
<SwitchField
    width="201px"
    height="unset"
    justifyContent="flex-start"
    position="absolute"
    top="0px"
    left="0px"
    label="Is completed"
    size="default"
    isDisabled={false}
    labelPosition="start"
    isChecked={switchFieldIsChecked}
    onChange={() => {
      switchFieldOnChange();
    }}
    onChange={() => setSwitchFieldIsChecked(!switchFieldIsChecked)}
    {...getOverrideProps(overrides, "SwitchField")}
 ></SwitchField>

Project Identifier

No response

Additional information

No response

lwang-79 avatar Aug 18 '23 12:08 lwang-79

Hey @lwang-79, thank you for reaching out. I was able to reproduce the issue, marking this as bug.

ykethan avatar Aug 18 '23 17:08 ykethan