Replacing toolbar contents and attributes intead of the whole toolbar… #7086
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.
Description
When a page is in non legacy structure mode, clicking the toolbar switcher button in order to show the cms structure board (sidebar), reloads the contents of the toolbar before making the structure board (sidebar) visible. And since our recent change in PR #7070, when contents of the toolbar are reloaded, the old toolbar element is replaced with the newly fetched one. However, the cms structure board does not update its reference to the toolbar object in this situation, and it ends up referencing the old, deleted toolbar. This causes a problem when the structure board tries to calculate the css style 'right' attribute, as it needs to account for the width of the toolbar object, and it ends up showing the toolbar outside the viewport. We didn't catch this when preparing PR #7070 because all of the pages we tested with initially were in legacy structure mode. And updating the toolbar after a plugin edit did not bring this issue, because the structure board was updated too in those cases.
Fix
Instead of replacing the old toolbar object with the new, we are now replacing only its contents and attributes. That way all the parts of the code that referenced the old toolbar object are still referencing the correct toolbar object.
Checklist
develop