Accessibility issue duplicate ids

Created on 26 January 2023, over 1 year ago
Updated 20 April 2023, about 1 year ago

Problem/Motivation

If a tooltip appears twice on a page the ID gets generated twice which is an accessibility issue.

Steps to reproduce

Have a tooltip appear twice
Inspect code

Proposed resolution

Alternative to using IDs?

Remaining tasks

Come up with a solution
patch
review

User interface changes

NA

API changes

NA

Data model changes

NA

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States smustgrave

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @smustgrave
  • @smustgrave opened merge request.
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Not sure the ID is needed.

  • πŸ‡¦πŸ‡ΊAustralia Mingsong πŸ‡¦πŸ‡Ί

    The ID provides the information where the tooltip comes from (which taxonomy term).

    Agree with that there shouldn't be any duplicated ID. So I would suggest that use another attributes instead.

    For example,

    <span class="tx-tooltip-text" tooltip-term-data="{{ tooltip_id }}">
    
  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Like that idea will get to that this week.

  • πŸ‡¦πŸ‡ΊAustralia Mingsong πŸ‡¦πŸ‡Ί

    Thanks @Stephen.

    Just a second thought, in some sites( use case), they might be not willing to expose term ids for security reason.

    I don't know if it is over precaution.

    Is there any way to add those information only for debug purpose? Something like debug mode of twig?

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Could add a config setting. Then in a preprocess hook pass a variable to the template to render the attribute or not.

    Would require updating the schema and update function too.

  • πŸ‡¦πŸ‡ΊAustralia Mingsong πŸ‡¦πŸ‡Ί

    How about the twig dump() function?
    https://twig.symfony.com/doc/3.x/functions/dump.html

    For example,

    <!-- tooltip_taxonomy
    
    {{ dump(tooltip_id) }}
    
    -->
    <span class="tx-tooltip-text">
    
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    I've never deployed that before won't that render all the time?

    I use that for just debugging.

  • πŸ‡¦πŸ‡ΊAustralia Mingsong πŸ‡¦πŸ‡Ί

    As the API document said

    The dump function won't display anything if the debug option on the environment is not enabled (to avoid leaking debug information on a production server).

    Also

    The dump function is not available by default. You must add the \Twig\Extension\DebugExtension extension explicitly when creating your Twig environment.

    Not sure if Drupal core adds that extension already. The idea is provides a way for developers to get the debug information if needed.
    Local development environment is not a Drupal contribute module needs to look after. So I believe providing the dump function in the template is good enough for that.

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Like that?

  • πŸ‡¦πŸ‡ΊAustralia Mingsong πŸ‡¦πŸ‡Ί

    Thanks @Stephen.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed about 1 year ago
  • Hi, effectively, for accessibility, I need to use tooltip_id like an ID, so if a term appear more than 1 time, there are duplicate IDs.

    I use aria-describedby on the parent span and id on the tooltip span.

    For exemple :

    <span role="tooltip" aria-describedby="{{ tooltip_id }}" class="tx-tooltip" tabindex="0">
    	{{ term_name }}
    	<span id="{{ tooltip_id }}" class="tx-tooltip-text">
    		{{ description }}
    	</span>
    </span>
    

    I need all of this to have a clean accessibility code.

    Is it possible to add an increment at the end of tooltip_id var after every use on a term ? Or something else ?

    Thx for your help

Production build 0.69.0 2024