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

fix(tabs): wait for TabPanel to mount before setting hidden #584

Merged
merged 1 commit into from Jun 11, 2020

Conversation

raunofreiberg
Copy link
Contributor

Thank you for contributing to Reach UI! Please fill in this template before submitting your PR to help us process your request more quickly.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code (Compile and run).
  • Add or edit tests to reflect the change (Run with yarn test).
  • Add or edit Storybook examples to reflect the change (Run with yarn start).
  • Ensure formatting is consistent with the project's Prettier configuration.

This pull request:

  • Creates a new package
  • Fixes a bug in an existing package
  • Adds additional features/functionality to an existing package
  • Updates documentation or example code
  • Other

Closes #561

I don't know if this is the correct solution, but it seems to make sense (?) and work.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 61bcce1:

Sandbox Source
lucid-brook-4u75o Configuration

@raunofreiberg
Copy link
Contributor Author

raunofreiberg commented May 12, 2020

I wanted to create a demo based on the CodeSandbox build of this branch, but none of the components seem to import for me.

https://codesandbox.io/s/hardcore-hertz-fu7d8

Maybe something up with the build or it's just me? 🤔


After further investigation this does not seem to be an anomaly but rather a bug –– I've opened a separate issue for this 👉#586


Anyhow, this is the code to reproduce #561

 function Component() {
  const ref = React.useRef<HTMLInputElement>(null);

  React.useEffect(() => {
    // Input does not get focused!
    ref?.current?.focus();
  }, []);

  return (
      <Tabs>
        <TabList>
          <Tab>Tab 1</Tab>
          <Tab>Tab 2</Tab>
        </TabList>
        <TabPanels>
          <TabPanel>
            <input ref={ref} />
          </TabPanel>
          <TabPanel>Panel 2</TabPanel>
        </TabPanels>
      </Tabs>
  );
}

@chaance chaance added Status: Investigation Type: Bug Something isn't working labels May 24, 2020
@chaance chaance merged commit ce691e1 into reach:master Jun 11, 2020
@raunofreiberg raunofreiberg deleted the fix/tabs-refs branch June 11, 2020 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Investigation Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tabs] Focusing an input inside a tab panel does not work on initial load
2 participants