hlxsites / merative2

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

Tagger feature for copy/paste order #367 #369

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.

https://github.com/hlxsites/merative2/issues/367

Issue Fixes https://github.com/hlxsites/merative2/issues/367

Description Test URLs Before (Changes from main): https://main--merative2--hlxsites.hlx.page/tools/tagger/index.html

After (Changes from this PR): https://tagger---feature-for-copy/paste-order-%23367--merative2--hlxsites.hlx.page/tools/tagger/index.html

Before (Changes from main): https://main--merative2--hlxsites.hlx.page/

After (Changes from this PR): https://tagger---feature-for-copy/paste-order-%23367--merative2--hlxsites.hlx.page/

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 * [5a43cd5](https://github.com/hlxsites/merative2/pull/369/commits/5a43cd56e331ae1ec1e61249c5a46017c69609d3) :x: (latest) * [fc5a256](https://github.com/hlxsites/merative2/pull/369/commits/fc5a2566028d3b3554e1a572a7b2385e33318dd0) :x:
7r0u8l3 commented 5 months ago

Duplicate.