Bug #98235
openPage tree selection lost after reloading of tree
Added by Riny van Tiggelen almost 2 years ago. Updated 8 months ago.
0%
Description
When a page is selected within the page tree and "Reload the tree from server" is used, the page selection is lost.
This is the case in current main (12) and 11, but was not the case in 10.
In 10, using the refresh icon the page selection stayed active.
Updated by Marco H almost 2 years ago
It also happens when you edit page properties and save them (I assume it probably triggers the "reload page tree" function)
Updated by Alexander Grein over 1 year ago
I think this "bug" comes with the new svg pagetree.
"bug" because its more a missing feature of the new tree.
In the old extjs version there was a lastSelectedNode property came from the stateHash array.
From the UX and accessibilty perspective, this is really bad.
[UPDATE]
After some research I found out that the web component of the page tree basically allows to set the active state via the JSON supplied by the TreeController.
The only missing thing in the pagesToFlatArray method is to set $item['checked'] of the last selected node to true.
Unfortunately I did not found any simple way to get this info at this place.
Maybe it has first to be stored somewhere in the user session?
Updated by Alexander Grein over 1 year ago
As far as i see, there are three problems at the moment:
- The current selected page is not stored in the backend user session to carry this information to e.g. the TreeController
- The selected page item does not get the property 'checked' = true inside TreeController ajax return, produced by its pagesToFlatArray method
- The pagetree does not get a refresh trigger to fetch a possible updated checked state
Here are some thoughts, how to fix it:
Take the current selected pageId inside eg. the SiteResolver middleware and store it inside the backend user session like so:
if (array_key_exists('id', $request->getQueryParams())) {
$GLOBALS['BE_USER']->setAndSaveSessionData('lastSelectedPage', $pageId);
}
Add this to TreeController::pagesToFlatArray method:
if ((int)$item['identifier'] === $backendUser->getSessionData('lastSelectedPage')) {
$item['checked'] = true;
}
Btw: The pagesToFlatArray method itself has some perfomance optimization potential.
Currenytly the getPageTreeRepository method is called multible times recursivly!
Since the getPageTreeRepository method always returns the same in one request, it could be handover as an additional parameter to the pagesToFlatArray method.
To trigger the refresh of the navigation, I'm currently not sure of the best way.
I think the PageLayoutController::renderContent method would be a good place to add something like this:
if ($this->id !== $this->getBackendUser()->getSessionData('lastSelectedPage')) {
$this->pageRenderer->addJsInlineCode('refreshPageTree', "top.document.dispatchEvent(new CustomEvent('typo3:pagetree:refresh'))");
}
Another idea is to add something like Tymoteusz Motylewski mentioned in https://forge.typo3.org/issues/92745
He talk about a JS API for the page tree, with a "selectNode" method.
Updated by Gerrit Code Review 11 months ago
- Status changed from Accepted to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81300
Updated by Gerrit Code Review 11 months ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81300
Updated by Gerrit Code Review 11 months ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81300
Updated by Garvin Hicking 8 months ago
Another issue that is probably related: If I create a new translation to a page, the page tree gets reloaded but the page that I translated from is no longer highlighted in the tree. That makes it hard to remember, which page is now getting translated, if you bulk-operate on a lot of pages.