Skip to content

Commit

Permalink
Order tab to remain rendered after the initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-17h committed Feb 11, 2025
1 parent 261cac2 commit b829d36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/volto/news/6492.bugfix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
You can now render the order side panel only when the 'Order' tab is active. Previously, the panel would render unnecessarily even when not active.@Abhishek-17h
The Order side panel now renders only when the "Order" tab is active. Previously, the panel would render unnecessarily even when inactive. @Abhishek-17h
14 changes: 8 additions & 6 deletions packages/volto/src/components/manage/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import BodyClass from '@plone/volto/helpers/BodyClass/BodyClass';
import { getCookieOptions } from '@plone/volto/helpers/Cookies/cookies';
import Icon from '@plone/volto/components/theme/Icon/Icon';
import forbiddenSVG from '@plone/volto/icons/forbidden.svg';
import loaderSVG from '@plone/volto/icons/loader.svg';
import { setSidebarTab } from '@plone/volto/actions/sidebar/sidebar';
import expandSVG from '@plone/volto/icons/left-key.svg';
import collapseSVG from '@plone/volto/icons/right-key.svg';
Expand Down Expand Up @@ -57,6 +58,7 @@ const Sidebar = (props) => {
);
const [size] = useState(0);
const [showFull, setshowFull] = useState(true);
const [isOrderTabRendered, setIsOrderTabRendered] = useState(false);

const tab = useSelector((state) => state.sidebar.tab);
const toolbarExpanded = useSelector((state) => state.toolbar.expanded);
Expand Down Expand Up @@ -101,6 +103,10 @@ const Sidebar = (props) => {
const onTabChange = (event, data) => {
event.nativeEvent.stopImmediatePropagation();
dispatch(setSidebarTab(data.activeIndex));

if (data.activeIndex === 2) {
setIsOrderTabRendered(true);
}
};

return (
Expand Down Expand Up @@ -187,17 +193,13 @@ const Sidebar = (props) => {
!!orderTab && {
menuItem: intl.formatMessage(messages.order),
pane:
tab === 2 ? (
isOrderTabRendered || tab === 2 ? (
<Tab.Pane
key="order"
className="tab-wrapper"
id="sidebar-order"
>
<Icon
className="tab-forbidden"
name={forbiddenSVG}
size="48px"
/>
<Icon className="tab-loader" name={loaderSVG} size="60px" />
</Tab.Pane>
) : null,
},
Expand Down
5 changes: 5 additions & 0 deletions packages/volto/theme/themes/pastanaga/extras/sidebar.less
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@
color: #bac5c7;
}

.tab-loader {
margin: calc(50% - 24px) auto;
color: #bac5c7;
}

header {
display: flex;
height: 60px;
Expand Down

0 comments on commit b829d36

Please sign in to comment.