Fix knowledge base aside renaming all nested articles - #25486
Closed
marifex wants to merge 1 commit into
Closed
Conversation
The aside tree nests child articles inside their parent element, so the descendant selectors used when updating an article title and illustration also matched every child. Renaming or changing the illustration of a parent (in particular the root) visually changed all its descendants until the page was refreshed. Update only the entry that belongs to the current article, as already done in AsideController::findEmptyMenus(). Fixes glpi-project#25394
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewPowered by Qodo |
Member
|
#25396 is open to resolve this issue as well. I missed linking it to the original issue. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checklist before requesting a review
Description
The knowledge base aside renders the article tree by nesting each child article inside its parent element. When an article was renamed (or its illustration changed), the title and illustration were updated with a descendant selector
[data-glpi-kb-article-id="<id>"] [data-glpi-kb-article-title], which also matched every nested child. Renaming a parent (in particular the root, which contains everything) therefore visually renamed all its descendants until the page was refreshed. The database was never affected.Both
#updateAsideTitle()and#updateAsideIllustration()now update only the entry that belongs to the current article, using the sameclosest(...) === articleguard already used byAsideController::findEmptyMenus()for the exact same nesting reason.Note on tests
The update methods are private and rely on the full controller and DOM, so a unit test would need significant setup. I verified the fix against the real aside DOM structure: the descendant selector matched the parent and all nested children, while the corrected logic matches only the current article. Happy to add a test where you prefer.