Complete refactor on push menu plugin#5954
Complete refactor on push menu plugin#5954dfsmania wants to merge 1 commit intoColorlibHQ:masterfrom
Conversation
✅ Deploy Preview for adminlte-v4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Single PushMenu instance instead of creating new ones per event - Proper separation: setupSidebarBreakPoint() vs updateStateByResponsiveLogic() - sidebar-open class only added on mobile (aligns with v3 behavior) - Persistence now opt-in via data-enable-persistence="true" - Config readable from data attributes on sidebar element - Remove unused menusClose() and dead constants BREAKING: enablePersistence defaults to false. Add data-enable-persistence="true" to sidebar element to restore. Based on PR #5954 by @dfsmania. Co-Authored-By: Diego Smania <diego.smania@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@puikinsh Your welcome, however the merged commit related to this work does not contains all the code commentaries that explains the decision of each logic implemented, and makes the code clear for a future maintainer. I don't get why you didn't just merge this PR directly. For example: This is some code I submitted here: /**
* Update the sidebar state based on the current screen size and the
* sidebarBreakpoint config value.
*/
updateStateByResponsiveLogic(): void {
if (this.isMobileSize()) {
// On mobile sizes, keep the sidebar collapsed unless explicitly opened
// by the user to prevent unintended collapse on scroll or resize events.
if (!this.isExplicitlyOpen()) {
this.collapse()
}
} else {
// On big screen sizes, keep the sidebar expanded unless in mini mode and
// explicitly collapsed.
if (!(this.isMiniMode() && this.isCollapsed())) {
this.expand()
}
}
}And now it's just like this (shorten, but harder to understand why that logic was applied): /**
* Update the sidebar state based on the current screen size and the
* sidebarBreakpoint config value.
*/
updateStateByResponsiveLogic(): void {
if (this.isMobileSize()) {
if (!this.isExplicitlyOpen()) {
this.collapse()
}
} else {
if (!(this.isMiniMode() && this.isCollapsed())) {
this.expand()
}
}
} |
|
@dfsmania You're absolutely right — those inline comments explain the reasoning behind each logic branch and are valuable for future maintainers. I should have merged the PR directly instead of rewriting the commit. I've just restored all the inline comments from your original PR in commit coming up next. Thanks for flagging this! |
Re-add the explanatory comments authored by @dfsmania that were stripped when the push-menu rewrite was merged. These comments document the reasoning behind each logic branch, making the code clearer for future maintainers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@puikinsh Thanks for considering this! When I get some time I will review the other Typescripts files to improve them. |
Refactor Push Menu Plugin (AdminLTE v4)
This PR delivers a complete refactor of the Push Menu plugin, focusing on correctness, maintainability, and behavioral alignment with AdminLTE v3.
Summary of changes
1. Improved code documentation
2. Clear separation of responsibilities
3. Sidebar behavior aligned with AdminLTE v3
sidebar-openclass is now explicitly added when the sidebar is opened on mobile viewports.4. Sidebar state persistence is now opt-in
5. Single PushMenu instance
Why this refactor?
The Push Menu is a core UI component that combines:
This refactor aims to:
No visual regressions are expected, only more consistent and predictable behavior.