Tagger feature for copy/paste order #367 #369
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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/