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

Accessible name from content is not computed correctly in case of display: block descendants #1054

Closed
Jym77 opened this issue Feb 1, 2022 · 7 comments · Fixed by #1200 or #1566
Closed
Labels
bug Report of unexpected or faulty behaviour in Alfa

Comments

@Jym77
Copy link
Contributor

Jym77 commented Feb 1, 2022

The accessible name specs say to join the content from descendants, but is not clear whether that should be done with or without space between them (w3c/accname#15). Back in #889 we decided to join them without space. This seems to be incorrect when there are spaces between the elements, or when the elements have display: block which adds visual spacing (new line) upon rendering.

<button>
  <span>inline</span><span>no space</span>
</button>

<button>
  <span>inline</span> <span>with space</span>
</button>

<button>
  <div>block</div><div>no space</div>
</button>

<button>
  <div>block</div> <div>with space</div>
</button>

<button>
  <div>block</div><span>inline</span>
</button>

<button>
  <span>inline</span><div>block</div>
</button>

Chrome (Version 97.0.4692.99) gives
"inlineno space", "inlinewith space", "block no space", "block with space", "block inline", "inline block"
Firefox (V 96.0.3) gives
"inlineno space", "inline with space", "block no space", "block with space", "block inline", "inline block"

Alfa gets no space between the elements in all cases.

@Jym77 Jym77 added the bug Report of unexpected or faulty behaviour in Alfa label Feb 1, 2022
@Jym77
Copy link
Contributor Author

Jym77 commented Jul 12, 2022

Current state:

  • It seem both Alfa, Chrome and Firefox add a space when there is inter-element space ("inline with space") 👍
  • Alfa doesn't add space when there is a block element, Chrome and Firefox do 👎

Resolution: change alfa-aria/fromDescendants to add space before and after each block element + trim result (to de-duplicate spaces).

@Jym77
Copy link
Contributor Author

Jym77 commented Aug 29, 2022

It seems we're still not good when the block element is nested inside an inline(-flex?) element with no other text 😕

@Jym77 Jym77 reopened this Aug 29, 2022
@2biazdk
Copy link

2biazdk commented Sep 5, 2023

I've tried to write some test cases we might use for this, based on my (limited) understanding of the issue:

  1. Test Case: Inline elements without space
    Description: Verify that accessible name is computed correctly for inline elements without space between them.
    HTML:

    <button>
      <span>inline</span><span>no space</span>
    </button>

    Expected Result: The accessible name should be "inlineno space".

  2. Test Case: Inline elements with space
    Description: Verify that accessible name is computed correctly for inline elements with space between them.
    HTML:

    <button>
      <span>inline</span> <span>with space</span>
    </button>

    Expected Result: The accessible name should be "inline with space".

  3. Test Case: Block elements without space
    Description: Verify that accessible name is computed correctly for block elements without space between them.
    HTML:

    <button>
      <div>block</div><div>no space</div>
    </button>

    Expected Result: The accessible name should be "block no space".

  4. Test Case: Block elements with space
    Description: Verify that accessible name is computed correctly for block elements with space between them.
    HTML:

    <button>
      <div>block</div> <div>with space</div>
    </button>

    Expected Result: The accessible name should be "block with space".

  5. Test Case: Mixed inline and block elements
    Description: Verify that accessible name is computed correctly for a mixture of inline and block elements.
    HTML:

    <button>
      <div>block</div><span>inline</span>
    </button>

    Expected Result: The accessible name should be "block inline".

  6. Test Case: Nested block inside inline
    Description: Verify that accessible name is computed correctly for a nested block element inside an inline element.
    HTML:

    <button>
      <span>inline</span><div>block</div>
    </button>

    Expected Result: The accessible name should be "inline block".

@2biazdk
Copy link

2biazdk commented Sep 5, 2023

@Jym77 Is the above useful? Can I add something else to help prepare this task?

@Jym77
Copy link
Contributor Author

Jym77 commented Sep 5, 2023

Perfect. Thanks.

@2biazdk
Copy link

2biazdk commented Jan 16, 2024

Is this issue related to #1203?

@Jym77
Copy link
Contributor Author

Jym77 commented Jan 16, 2024

Is this issue related to #1203?

@2biazdk it may boils down to the same problem, but it looks slightly different…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report of unexpected or faulty behaviour in Alfa
Projects
Archived in project
3 participants