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

SwipeableViews onChangeIndex event handler never called when used in the Tabs component #22351

Closed
2 tasks done
zachsa opened this issue Aug 25, 2020 · 2 comments
Closed
2 tasks done
Labels
component: tabs This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it

Comments

@zachsa
Copy link

zachsa commented Aug 25, 2020

Using Tabs with SwipeableViews, the first time a Tab is changed there is no sliding animation. This is the case in the Material UI documentation: https://material-ui.com/components/tabs/, and also in my own code.

I don't know if this is a problem with SwipeableViews or Material UI, but since the problem is present in the Material UI docs I thought it best to start here.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

I've attached a giff that shows that the first time a tab is changed the swipeable animation doesn't fire (this is also the case in Material UI documentation as linked to above).

In my code:

<SwipeableViews
  axis="x"
  index={activeTabIndex}
  onChangeIndex={index => {
    console.log('cb fired', index)
    setActiveTabIndex(index)
  }}
</SwipeableViews>

I can see that the onChangeIndex handler doesn't ever get called.

Expected Behavior 🤔

The swipeable animation should fire on every change. And the onChangeIndex handler should be called.

missing-swipeable-animation

@zachsa zachsa added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 25, 2020
@eps1lon
Copy link
Member

eps1lon commented Aug 25, 2020

Duplicate of oliviertassinari/react-swipeable-views#599

@eps1lon eps1lon closed this as completed Aug 25, 2020
@eps1lon eps1lon added duplicate This issue or pull request already exists external dependency Blocked by external dependency, we can’t do anything about it and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 25, 2020
@oliviertassinari oliviertassinari added the component: tabs This is the name of the generic UI component, not the React module! label Feb 13, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 13, 2021

The regression has happened in v4.9.12...v4.9.13:

I could isolate the regression, coming from #20781. And more specifically:

      aria-selected={selected}
      disabled={disabled}
      onClick={handleChange}
-     tabIndex={selected ? 0 : -1}
      {...other}
    >

https://github.com/mui-org/material-ui/pull/20781/files#diff-ccf739a564e283358cc8ff2bf3556de13494bcc7696137998e8051446f20a65eR144.

I have no idea why. I'm proposing a fix on react-swipeable-view side, leveraging https://youtu.be/cCOL7MC4Pl0?t=1188.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tabs This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it
Projects
None yet
Development

No branches or pull requests

3 participants