Skip to content

XWIKI-23286: Panel toggles and handles inconsistencies #4140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,19 @@ require(['jquery', 'jquery-ui'], function($) {
return valueIsSimilarToDefault(document.body.style.getPropertyValue('--panel-column-' + side + '-width'), side);
};
let updateLocalStorageValueForSide = function (side) {
// If the panel is not here, do not take any action on local storage.
// The user cannot act on or view the width preference, it should not be updated.
if($( '#' + side + 'Panels' ).length === 0) return;
// We only update the local storage when the last value is different enough from the default value.
// This is important to keep this as long as we don't have a proper UI to reset the panel column size.
// IMO it makes sense to keep it even when we eventually have this reset UI.
if (!currentValueIsSimilarToDefault(side)) {
localStorage.setItem(localStoragePrefix + side,
document.body.style.getPropertyValue('--panel-column-' + side + '-width'));
} else {
// If the values are similar, we remove whatever was stored in the localStorage.
// If the values are similar and the panel is actually here, we remove whatever was stored in the localStorage.
// The panels are not in the DOM if: it's deactivated for everyone by admins or this page layout doesn't contain
// panels.
localStorage.removeItem(localStoragePrefix + side);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@
& #leftPanels {
order: 1;
width: ~"var(--panel-column-left-width)";
padding-right: ~"calc(var(--grid-gutter-width) / 2)";
}

& #rightPanels, & #editPanels {
& #rightPanels {
order: 3;
width: ~"var(--panel-column-right-width)";
padding-left: ~"calc(var(--grid-gutter-width) / 2)";
}

/* Depending on the admin parameters, we want to change the default size. */
Expand All @@ -51,10 +49,15 @@
We add a HIDDEN block in between the two dashes. With the LESS4J lexer, inline comments are good for this.
Once this file is migrated to native CSS, this hack can be removed. */
&.hideleft {
-/**/-panel-column-left-width: 0;

& #leftPanels {
display: none;
/* When the screen is small enough, we keep panels shown.
Note that templates to generate panel columns only generate them if the panels are not hidden by admin choice.
ie. this media query does not short-circuit the admin preference. */
@media (min-width: @screen-md-min) {
-/**/-panel-column-left-width: 0;

& #leftPanels {
display: none;
}
}
}

Expand All @@ -67,10 +70,15 @@
}

&.hideright {
-/**/-panel-column-right-width: 0;

& #rightPanels {
display: none;
/* When the screen is small enough, we keep panels shown.
Note that templates to generate panel columns only generate them if the panels are not hidden by admin choice.
ie. this media query does not short-circuit the admin preference. */
@media (min-width: @screen-md-min) {
-/**/-panel-column-right-width: 0;

& #rightPanels {
display: none;
}
}
}

Expand All @@ -83,11 +91,16 @@
}

&.hidelefthideright {
-/**/-panel-column-left-width: 0;
-/**/-panel-column-right-width: 0;

& #leftPanels, & #rightPanels {
display: none;
/* When the screen is small enough, we keep panels shown.
Note that templates to generate panel columns only generate them if the panels are not hidden by admin choice.
ie. this media query does not short-circuit the admin preference. */
@media (min-width: @screen-md-min) {
-/**/-panel-column-left-width: 0;
-/**/-panel-column-right-width: 0;

& #leftPanels, & #rightPanels {
display: none;
}
}
}

Expand Down Expand Up @@ -157,8 +170,7 @@
resize: vertical;
}

.main, #editcolumn,
#leftPanels, #rightPanels, #editPanels {
.main, #editcolumn, #leftPanels, #rightPanels {
position: relative;
padding-top: (@grid-gutter-width / 2);
padding-bottom: (@grid-gutter-width / 2);
Expand Down Expand Up @@ -208,6 +220,15 @@ again or the page is reloaded (because the toggler is hidden until then). */
#rightPanelsToggle:hover, #rightPanelsToggle:focus {
opacity: 1;
}

/* When the display is large enough, we add padding on the outer sides of the panel columns. */
#leftPanels {
padding-right: ~"calc(var(--grid-gutter-width) / 2)";
}

#rightPanels {
padding-left: ~"calc(var(--grid-gutter-width) / 2)";
}
}

body#body #rightPanelsToggle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@
#set ($editorPanels = $editorPanelsHistory)
#end
#if ($!editorPanels != '')
## Similar to the toggle defined in rightpanels.vm
<button id="rightPanelsToggle" class="btn btn-default"
title="$escapetool.xml($services.localization.render('panels.column.right.toggle.hint'))" type="button">
$services.icon.renderHTML('caret-right')
<span class="sr-only">$services.localization.render('panels.column.right.toggle.hint')</span>
</button>
#set ($editorPanels = $editorPanels.split(','))
<div id="editPanels" class="panels editor">
<div id="rightPanels" class="panels editor">

## Convert the list of panels to panel (UIExtension) IDs
#set ($panelIDList = [])
Expand All @@ -57,7 +63,9 @@
$services.rendering.render($panelUIExtension.execute(), "xhtml/1.0")
#end
#end

## Similar to the resize handle defined in rightpanels.vm
<span role="button" tabindex="0" class="ui-resizable-handle ui-resizable-w"
title="$escapetool.xml($services.localization.render('panels.column.right.resizeHandle.hint'))"></span>
</div>
#end
#end
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#if(!$request.getParameter("forceLeftPanels"))
<button id="leftPanelsToggle" class="btn btn-default" title="$escapetool.xml($services.localization.render('panels.column.left.toggle.hint'))">
$services.icon.renderHTML('caret-right')
<div class="sr-only">$services.localization.render('panels.column.left.toggle.hint')</div>
<span class="sr-only">$services.localization.render('panels.column.left.toggle.hint')</span>
</button>
#end
<div id="leftPanels" class="panels left panel-width-$!{leftPanelsWidth}"#if($showLeftPanels != "1" && $request.getParameter("forceLeftPanels")) style="display: none;"#end>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if(!$request.getParameter("forceRightPanels"))
<button id="rightPanelsToggle" class="btn btn-default" title="$escapetool.xml($services.localization.render('panels.column.right.toggle.hint'))">
$services.icon.renderHTML('caret-right')
<div class="sr-only">$services.localization.render('panels.column.right.toggle.hint')</div>
<span class="sr-only">$services.localization.render('panels.column.right.toggle.hint')</span>
</button>
#end
<div id="rightPanels" class="panels right panel-width-$!{rightPanelsWidth}"#if($showRightPanels != "1" && $request.getParameter("forceRightPanels")) style="display: none;"#end>
Expand Down