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

[BUG]: Tabs are not usable right now with re-render #425

Open
savutsang opened this issue Mar 28, 2022 · 0 comments
Open

[BUG]: Tabs are not usable right now with re-render #425

savutsang opened this issue Mar 28, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@savutsang
Copy link
Contributor

Current behaviour

On every change to the tabs content (a re-render via state or redux store), it create a new Tabs and TabPanel instead of updating the existing one. Because the DOM is destroyed and recreated, the currently focused element are lost. Could also have many problems for other things like rendering a heavy Chart.

Expected behaviour

It should update the current panel, keeping the focus on the same element.

Steps to reproduce

export const TestComponent: React.VFC = () => {
  const [value, setValue] = useState("");
  return (
    <Tabs
      tabs={[
        {
          title: "Panel",
          panelContent: <input value={value} onChange={e => setValue(e.currentTarget.value)} />
        }
      ]}
    />
  );
};

Context (version, environment, browser)

Chrome
@equisoft/design-elements-react: 4.0.0
react: 17.0.2
react-dom: 17.0.2

Screenshots (optional)

Additional details (optional)

The problem is key is always changed because they are tight to useMemo() + uuid(). If we are able to specify our key manually, it could be one way to fix, or use another strategy.

As a reference, the bug didn't happen in MUI: https://mui.com/components/tabs/#main-content

@savutsang savutsang added the bug Something isn't working label Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant