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

Focus lost on every keystroke when placing a NumberInput inside a CardWrapper #14

Closed
janniksam opened this issue Oct 10, 2022 · 3 comments

Comments

@janniksam
Copy link

janniksam commented Oct 10, 2022

It seems like something is wrong with the CardWrapper.
I'm a very fresh web development beginner (coming from the .NET World), so it probably is just me, but I found a very strange behavior:

This is working. It only rerenders the updated value-attribute to the DOM every time I enter a character into the NumberInput.

const Test= () => {
  const [limit, setLimit] = useState('0.0');
  return (
    <NumberInput
      minW="40%"
      maxW="40%"
      ml={5}
      clampValueOnBlur={false}
      defaultValue={0}
      precision={2}
      onChange={(enteredLimit) => setLimit(enteredLimit)}
      value={limit}
      step={0.2}
    >
      <NumberInputField />
    </NumberInput>
  );
};

This is NOT working. It rerenders the whole outer div every time I type a character into the number input, thus loosing the keyboardfocus every time I type a character into the NumberInput:

const Test = () => {
  const [limit, setLimit] = useState('0.0');
  return (
    <CardWrapper>
      <NumberInput
        minW="40%"
        maxW="40%"
        ml={5}
        clampValueOnBlur={false}
        defaultValue={0}
        precision={2}
        onChange={(enteredLimit) => setLimit(enteredLimit)}
        value={limit}
        step={0.2}
      >
        <NumberInputField />
      </NumberInput>
    </CardWrapper>
  );
};

I must be doing something terribly wrong. Do you have any idea, what could be wrong?

@juliancwirko
Copy link
Member

Thanks for reporting. I will check it asap!

@juliancwirko
Copy link
Member

Confirmed the bug, and it should already be fixed in v2.2.1

@janniksam
Copy link
Author

I can indeed confirm it is fixed in v2.2.1. Thank you!

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

2 participants