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

Selected tab has no css applied #450

Open
EasyLifeBertolla opened this issue Mar 16, 2022 · 5 comments
Open

Selected tab has no css applied #450

EasyLifeBertolla opened this issue Mar 16, 2022 · 5 comments

Comments

@EasyLifeBertolla
Copy link

noticed in version v4.0.1
current solution: backporting to v.3.2.3

Selecting a tab applies the react-tabs__tab--selected class to the chosen <li> element. CSS is being applied, but it's not showing on the selected item. Clicking anywhere else makes styling visible again.
Using Chrome developer tools, it seems like the content of the li tag is not being rendered, and therefore the CSS is neither.

@danez
Copy link
Collaborator

danez commented Mar 17, 2022

Could you create an example for this problem?

Because I cannot reproduce this on https://reactcommunity.org/react-tabs/

@danez danez closed this as completed Apr 17, 2022
@mitchell-robinson
Copy link

mitchell-robinson commented Jan 4, 2023

@danez @EasyLifeBertolla I was able to recreate this on https://reactcommunity.org/react-tabs/, and also found a workaround.

To recreate
I used the Super Mario example, and added a border-bottom rule to .react-tabs__tab--selected
image
After which, the border-bottom rule is not applied to a tab on the initial click, but appears once you've clicked anywhere after the initial new tab click.

Workaround
This doesn't happen if I set the focusTabOnClick property of the Tabs component to FALSE. Clicking a new tab applies the border-bottom rule. However, if I click a new tab, then click that same tab again, the styling disappears.

It seems to have something to do with the rendering of the Tab title. In each scenario (focusTabOnClick true or false), styles apply to .react-tabs__tab--selected whenever there is content in the <li>
image

But the styling disappears whenever an ellipsis is the content of the tab <li>:
image
The above happens on the initial click when focusTabOnClick={true} and on a second-click of the tab whenever focusTabOnClick={false}

Hope this helps.

@danez danez reopened this Jan 4, 2023
@mitchell-robinson
Copy link

mitchell-robinson commented Jan 4, 2023

@danez found out what's happening.
In my case, this was specific to the border-bottom rule. (using a border-left didn't have the same issue).

I found that the &:focus &:after rule of the stylesheet was causing the border-bottom rule to not appear.

I commented out the &:after rules in the stylesheet, and my border-bottom rule works in all scenarios without needing to adjust any props.

I'm assuming the &:after rule there was meant to support the default styling? This might just be a workaround for us trying to underline our selected tabs.

@danez
Copy link
Collaborator

danez commented Jan 4, 2023

Good catch! The :after class was used to hide the outline when selecting the tab. But since the last major version this outline was removed anyway, so also this :after class can be removed. I will take care of this.

Thanks you for investigating! 💜

@EasyLifeBertolla
Copy link
Author

Sorry if I only come back on this now. Thanks for the troubleshooting. I noticed that the issue persists in the latest 6.0.0 release. There might be a reason for that. For me, it was enough to overwrite the rule in my custom CSS like this:

.react-tabs__tab--selected:focus:after {
  background: transparent;
  height: 0;
  content: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

I know this might not be the best solution, but it does the trick for me. Thanks for all your help!

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