hlxsites / merative2

Merative.com site on Franklin
https://merative.com
Apache License 2.0
2 stars 9 forks source link

Issue 367 - Tagger - Added global array to track the tag order #368

Closed 7r0u8l3 closed 5 months ago

7r0u8l3 commented 5 months ago

This script now includes a global array selectedOrder to track the order of selected tags. The toggleTag function has been modified to update this array when a tag is selected or deselected. The displaySelected function uses this array to display the tags in the order they were selected, ensuring that the selection order is consistent regardless of their DOM order.

The toggleTag function now considers both the title and the category of a tag when toggling its selection. The displaySelected function uses the updated selectedOrder array, which contains objects with title and category properties, to display the selected tags. The clear button event listener in the init function now resets the selectedOrder array when clearing the selection. This should ensure that tags with duplicate names in different categories are handled correctly, and their selection order is maintained as expected.

Instead of using querySelector with :contains, it iterates over all categories and checks their h2 text content to find the matching category. Once the correct category is found, it searches for the tag with the matching title within that category. This approach should resolve the error and correctly handle the selection and display of tags, even when they have duplicate names in different categories.

Each tag is identified by both its title and its category, allowing for proper handling of duplicate tag names in different categories. The selectedOrder array now stores objects with title and category properties. The displaySelected function has been updated to use this additional information when displaying selected tags. This approach should resolve the issue with duplicate tag names and ensure that tags are correctly identified and displayed based on both their title and category.

367

Issue

Fixes #367

Description

Test URLs

aem-code-sync[bot] commented 5 months ago

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed. In case there are problems, just click a checkbox below to rerun the respective action.

Commits * [9b476bc](https://github.com/hlxsites/merative2/pull/368/commits/9b476bc00264f187724397dd4438a3307c765ca1) :x: (latest) * [f22efc7](https://github.com/hlxsites/merative2/pull/368/commits/f22efc7d84cf9b1d8d14eca99a0fed5c2d234a12) :x: * [8a9d1b8](https://github.com/hlxsites/merative2/pull/368/commits/8a9d1b81a894266d55c8cf28515c1012a9b5c14a) :white_check_mark:
aem-code-sync[bot] commented 5 months ago
Page Scores Audits Google
/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
/tools/tagger/index.html PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI