Project

General

Profile

Actions

Bug #98235

open

Page tree selection lost after reloading of tree

Added by Riny van Tiggelen over 1 year ago. Updated 5 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Pagetree
Target version:
-
Start date:
2022-08-31
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Stabilization Sprint

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.

Actions #1

Updated by Oliver Hader over 1 year ago

  • Category set to Pagetree
Actions #2

Updated by Georg Ringer over 1 year ago

  • Status changed from New to Accepted
Actions #3

Updated by Marco H over 1 year ago

It also happens when you edit page properties and save them (I assume it probably triggers the "reload page tree" function)

Actions #4

Updated by Alexander Grein about 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?

Actions #5

Updated by Alexander Grein about 1 year ago

As far as i see, there are three problems at the moment:

  1. The current selected page is not stored in the backend user session to carry this information to e.g. the TreeController
  2. The selected page item does not get the property 'checked' = true inside TreeController ajax return, produced by its pagesToFlatArray method
  3. 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.

Actions #6

Updated by Benni Mack 11 months ago

  • Sprint Focus set to Stabilization Sprint
Actions #7

Updated by Gerrit Code Review 7 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

Actions #8

Updated by Gerrit Code Review 7 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

Actions #9

Updated by Gerrit Code Review 7 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

Actions #10

Updated by Garvin Hicking 5 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.

Actions

Also available in: Atom PDF