department-of-veterans-affairs / va.gov-cms

Editor-centered management for Veteran-centered content.
https://prod.cms.va.gov
GNU General Public License v2.0
97 stars 69 forks source link

SPIKE: Define long-term solution for setting Accordion header levels #12255

Closed wesrowe closed 1 year ago

wesrowe commented 1 year ago

Description

We need to pull in multiple perspectives (FE eng, accessibility, BE eng) to determine a sustainable, governable way to ensure that accordion headers are set correctly in the hierarchy of the template they appear in.

High-level requirements of the solution:

Acceptance Criteria

CMS Team

Please check the team(s) that will do this work.

laflannery commented 1 year ago

Some resources for you:

laflannery commented 1 year ago

Talking with Josh and investigating the proposed solution, I wanted to document that what has been proposed will not impact FE accordions that have been created in Drupal using the Q&A group or Q&A section content blocks

jtmst commented 1 year ago

Spike Findings

The main takeaway for this spike is that we should be able to accomplish much more accurate accordion headers by creating a plugin that modifies the dom after the html files are built in content build. Examples of this being done are in src/site/stages/build/plugins/modify-dom, and the most similar example the developer that works on this could reference would be in src/site/stages/build/plugins/modify-dom/add-id-to-subheadings.js.

Methodology

The plugin we create is going to run alongside the other plugins in src/site/stages/build/plugins/modify-dom/index.js where each html file is stored individually to have these modifications run against them. We are going to need to create logic that finds va-accordion components with the data-template attributes we are targeting (eg collapsible_panel) and works backwards to find the closest previous div with a data-template of paragraph/wysiwyg that contains a header. We can reassign the accordion header levels based on that header.

Potential Issues

Dev Considerations