Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StepperField controlled element doesn't update UI on external state changes #1283

Closed
2 tasks done
alharris-at opened this issue Feb 9, 2022 · 0 comments
Closed
2 tasks done
Assignees

Comments

@alharris-at
Copy link
Contributor

alharris-at commented Feb 9, 2022

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Other

How is your app built?

Create React App

Please describe your bug.

If I set up a controlled StepperField component, everything works swimmingly until I update the state from outside the onChange event of the component itself. The underlying value DOES update, but the UI does not. Subsequent changes to the ui controls will catch the component up however.

What's the expected behaviour?

External changes to StepperField value will update the UI accordingly.

Help us reproduce the bug!

Set up the App

npx create-react-app bug-repro
cd bug-repro
npm i @aws-amplify/ui-react
cat > src/App.js <<- EOM
import { useState } from 'react';
import '@aws-amplify/ui-react/styles.css';
import { AmplifyProvider, Flex, Heading, StepperField, Text, Button, defaultTheme } from "@aws-amplify/ui-react";

export default function App() {
  const [stepperFieldInputValue, setStepperFieldInputValue] = useState(0);
  const setStepperFieldValueClick = () => setStepperFieldInputValue(9);
  return (
    <AmplifyProvider theme={defaultTheme}>
      <Heading level={2}>StepperField Bug Repro</Heading>
      <Flex direction="row">
        <StepperField value={stepperFieldInputValue} onStepChange={(value) => setStepperFieldInputValue(value)} />
        <Text>Current Value: {stepperFieldInputValue}</Text>
        <Button onClick={setStepperFieldValueClick}>Set StepperFieldValue</Button>
      </Flex>
    </AmplifyProvider>
  );
}
EOM
npm start

Then go into the ui , click 'Set StepperFieldValue', then update the value using ui controls.

Code Snippet

See Repro Steps

Additional information and screenshots

This seems closely related to #1284, but opened as a separate issue in case they're not the same underlying issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants