Skip to content

[EuiAccordion] Should move focus to opened content #4224

Closed

Description

@myasonik

Accordions should move focus to the newly opened content when toggled

Activity

  1. Dishebh commented on Dec 10, 2020

    @Dishebh
    Contributor

    @myasonik please correct me here if needs be - Does this mean that when the buttonContent is clicked, its children should be underlined?

    A buttonContent prop defines the content of the clickable area. On click it will expose the children and animate based on the height of those children.

  2. myasonik commented on Dec 10, 2020

    @myasonik
    ContributorAuthor

    I don't think we need to tweak any styles (and I don't think we'll get an underline by default) but I think you get the idea.

    Just to restate to make sure we're on the same page:
    There's a button.euiAccordion__button. When that gets clicked it reveals a div.euiAccordion__childWrapper. When that happens, we should also move focus to that div. You'll need to add tabIndex={-1} (to allow it to receive focus) and then call .focus() on a ref to that div. Hopefully that makes sense?

  3. chandlerprall commented on Dec 10, 2020

    @chandlerprall
    Contributor

    @myasonik should the content container receive focus, or should we shift focus into the first tabbable element within the container? (and what happens if there is no tabbable content)

  4. myasonik commented on Dec 10, 2020

    @myasonik
    ContributorAuthor

    TLDR We just want to move focus to the container here.


    I can see it feeling kind of silly - it's only moving focus forward 1 element basically - but it gives definite feedback to a screen reader that the button did something. On the flip side, skipping ahead to tabbable content could be confusing because, unlike modals, for example, where we sometimes skip ahead to the close button or primary input, there's no reasonable expectation of what will generally be inside an accordion. Modals on the other hand will always have a close button, and have some basic structural elements users can assume so it's safer to skip ahead to tabbable elements which we assume that users will want to interact with.

  5. K-Kumar-01 commented on Dec 11, 2020

    @K-Kumar-01
    Contributor

    @chandlerprall @myasonik
    I have made the desired changes. However, I am failing the tests for accordion with the updated code. I have never worked with tests before and don't know much about them.
    I am running the command yarn run test-unit
    Adding some images for your reference.
    DeepinScreenshot_20201211153120
    DeepinScreenshot_20201211153135
    DeepinScreenshot_20201211153231
    DeepinScreenshot_20201211153242

    Also, this is causing me a problem to commit.

  6. Dishebh commented on Dec 11, 2020

    @Dishebh
    Contributor

    @K-Kumar-01, please always say/ask before taking up an issue, there are also some chances that someone else might be working on it beforehand 😄

  7. K-Kumar-01 commented on Dec 11, 2020

    @K-Kumar-01
    Contributor

    @K-Kumar-01, please always say/ask before taking up an issue, there are also some chances that someone else might be working on it beforehand

    I am really sorry. You can feel free to go on. I will stop my work.
    I apologize for not requesting the issue. I will be more careful onwards

  8. Dishebh commented on Dec 11, 2020

    @Dishebh
    Contributor

    It is totally cool, you can work on it 😄

  9. chandlerprall commented on Dec 14, 2020

    @chandlerprall
    Contributor

    @K-Kumar-01 those issues when running tests are representing your changes to what is outputted to the DOM - you can re-run the tests with the -u flag ( yarn test-unit -u ) which instructs Jest to accept the new changes and modify the snapshot files - you'll need to commit those additional changes as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions