Skip to content

Build your personal knowledge base with Trilium Notes

fix(mobile): size expanded submenus from their content

Elian Doran0071275e0d56
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 4ab85522db..01d0f9b839 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -1685,6 +1685,7 @@ body.mobile .dropdown-submenu > .dropdown-menu {
top: unset !important;
margin-top: 0 !important;
width: 100%;
+ max-height: none;
}
#context-menu-container,
diff --git a/apps/client/src/stylesheets/theme-next/base.css b/apps/client/src/stylesheets/theme-next/base.css
index c4f1fef948..3bf657245c 100644
--- a/apps/client/src/stylesheets/theme-next/base.css
+++ b/apps/client/src/stylesheets/theme-next/base.css
@@ -487,6 +487,14 @@ body.mobile .dropdown-menu {
padding: 0 !important;
backdrop-filter: unset !important;
+ /* The submenu sits in a track that grows from 0fr to 1fr, so the expanded
+ height is whatever the items measure. The toggle's track is max-content
+ rather than auto: an auto track absorbs the slack mid-transition and
+ visibly stretches the item. */
+ display: grid !important;
+ grid-template-rows: max-content 0fr;
+ transition: grid-template-rows 100ms ease-in;
+
.dropdown-toggle {
padding: var(--dropdown-menu-padding-vertical) var(--dropdown-menu-padding-horizontal);
}
@@ -495,17 +503,27 @@ body.mobile .dropdown-menu {
--menu-background-color: --menu-submenu-mobile-background-color;
--bs-dropdown-divider-margin-y: 0.25rem;
border-radius: 0;
- max-height: 0;
- transition: max-height 100ms ease-in;
display: block !important;
+ /* Counters align-items: center from style.css, which would let the
+ submenu keep its content height instead of following the track. */
+ align-self: stretch;
+ min-height: 0;
+ overflow: hidden;
+
+ /* The vertical padding grows with the track; applying it at once would
+ hold the collapsed submenu open by that much. */
+ padding: 0 0.75rem !important;
+ transition: padding 100ms ease-in;
+
&.show {
- max-height: 1000px;
- padding: 0.5rem 0.75rem !important;
+ padding-block: 0.5rem !important;
}
}
&.submenu-open {
+ grid-template-rows: max-content 1fr;
+
.dropdown-toggle {
padding-bottom: var(--dropdown-menu-padding-vertical);
}