Coder Social home page Coder Social logo

Comments (3)

brandongregoryscott avatar brandongregoryscott commented on June 15, 2024 1

Hmm, this looks like a regression from the V7 changes. The same code looks fine in v6.13.3: https://codesandbox.io/s/issue-1622-selected-tab-doc3fp

It looks like using the Link component instead of an a tag directly should also style correctly, as a workaround on v7:

<Tab
  href={hash}
  is={Link}
  isSelected={selectedIndex === index}
  appearance="primary"
  key={tab}
  onClick={() => setSelectedIndex(index)}
>
  {tab}
</Tab>

from evergreen.

brandongregoryscott avatar brandongregoryscott commented on June 15, 2024 1

I do think you're on to something with the incorrect selectors being generated - I think that's an edge case in the newer ui-box features that wasn't handled properly. The selector for _current maps to this:

_current: '&[aria-current="page"],&[aria-selected="true"]',

The nested selectors defined in the theme (i.e. :before and :after) should be attached to both of these:

'&:before': {
transform: 'scaleY(1)'
},
'&:focus': {
color: 'colors.blue600'
}

However, these are only being attached to the last of the parent selectors, as you noted:

-.ub-tfrm_qu4iyp_fiauus[aria-current="page"], .ub-tfrm_qu4iyp_fiauus[aria-selected="true"]:before {
+.ub-tfrm_qu4iyp_fiauus[aria-current="page"]:before, .ub-tfrm_qu4iyp_fiauus[aria-selected="true"]:before {
  transform: scaleY(1);
}

I should have a PR up there to fix it soon, and then we can bring it in here. It seems to solve the issue without having to change the existing tab.js theme file.

image

Once this lands, I don't think you should need the aria-selected={selectedIndex === index} prop anymore (since it sets aria-current="page" internally if isSelected is true).

from evergreen.

limgit avatar limgit commented on June 15, 2024

Thanks for the reply! I'll use the workaround until a fix is applied.

Edit: FYI for future readers: I added aria-selected={selectedIndex === index} prop to the Tab component (along with isSelected={selectedIndex === index}) for workaround(Using Link component styles the text little bit differently, which is not what I wanted).

from evergreen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.