Skip to content

Commit

Permalink
* sidebar: fix preserve collapse state not work in sidebar.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Aug 23, 2024
1 parent 6c4d9d6 commit 4ea4ccf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/sidebar/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'zui-dev';
import {Sidebar} from './src/main';

onPageUpdate(() => {
const sidebar = new Sidebar('#sidebar', {width: 300, parent: 'body'});
const sidebar = new Sidebar('#sidebar', {width: 300, parent: 'body', preserve: 'sidebar'});
console.log('> sidebar', sidebar);

const sidebarRight = new Sidebar('#sidebarRight', {
Expand All @@ -11,6 +11,7 @@ onPageUpdate(() => {
parent: 'body',
side: 'right',
animation: 1000,
preserve: 'sidebarRight',
// toggleBtn: false,
});
console.log('> sidebarRight', sidebarRight);
Expand Down
3 changes: 1 addition & 2 deletions lib/sidebar/src/vanilla/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ export class Sidebar extends Component<SidebarOptions, {
this._minWidth = calcSize(minWidth, containerWidth);
this._maxWidth = calcSize(maxWidth, containerWidth);
this._defaultWidth = Math.max(this._minWidth, Math.min(this._maxWidth, calcSize(width || $element.width(), containerWidth)));
this._width = (preserve ? store.get(this._storeID) : null) || this._defaultWidth;

this._width = (preserve ? store.get(this._storeID) : null) ?? this._defaultWidth;

this.render();

Expand Down

0 comments on commit 4ea4ccf

Please sign in to comment.