"more" actions always show root actions
Describe the bug
The "more" button (three dots on the sidebar) are not correctly updated if you start for example from /contents view in the site root and navigate.
To Reproduce Steps to reproduce the behavior:
- Go to homepage
- Click on "Contents"
- Click on one child (possibly a folderish content)
- Click on "..." button (on the toolbar)
- The opened menu has the title of the root and not the context. And it has the actions of the root (only sharing) and not the ones for the context
Expected behavior
See the current folder actions (state, view, history, sharing) and the title of the current context in the opened menu (in the toolbar)
Software (please complete the following information):
Tested also here: https://volto.kitconcept.com/
@cekk and @sneridagh I worked on this issue for a while to observe this issue carefully and I found that this issue occurs because toolbar doesn't get refreshed when we move via contents section from a folder to another folder that's why ... ('more') button of a different folder (Not on Home page) showing root contents but if you refresh the page then you will find that toolbar gets refreshed and more button shows non root contents.
And also toolbar gets refreshed when we move via navigation bar from a page to another page but not getting refreshed via contents section.
So, I can fix this issue but I'm looking for an optimal way. Do you have any suggestions, How should I fix these issues in a optimal way.
below given video shows when this issue occurs. https://youtu.be/tulgQOrR6SA
I think this code should check if the path is different and rerender the toolbar: https://github.com/plone/volto/blob/master/src/components/manage/Toolbar/Toolbar.jsx#L212
Maybe you can debug that part of the code to see if you can find something. If not, let me know what your plan for the implementation is and I can see if it's optimal or can be improved.
it is not enough to update only the actions and the type but also the content, for example to update the types of views, adding:
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.pathname !== this.props.pathname) {
this.props.getContent(getBaseUrl(nextProps.pathname));
this.props.listActions(getBaseUrl(nextProps.pathname));
this.props.getTypes(getBaseUrl(nextProps.pathname));
}
...
}
...
connect(
(state, props) => ({
actions: state.actions.actions,
token: state.userSession.token,
userId: state.userSession.token
? jwtDecode(state.userSession.token).sub
: '',
content: state.content.data,
pathname: props.pathname,
types: filter(state.types.types, 'addable'),
unlockRequest: state.content.unlock,
}),
{ getContent, getTypes, listActions, setExpandedToolbar, unlockContent },
),
...