Repository navigation
fix(ArrowListView): hide arrows when item count is below maxVisibleItems - #728
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRestores maxVisibleItems-based behavior in ArrowListView: lists at or below the limit hide arrows without occupying space, while longer lists retain arrows with position-aware interaction and correct popup sizing. Flow diagram for ArrowListView arrow visibility and sizingflowchart TD
A[ArrowListView receives item count] --> B{count > maxVisibleItems}
B -->|No| C[interactive is false]
C --> D[Hide arrows and remove spacing]
D --> E[Exclude arrow area from popup height]
B -->|Yes| F[interactive is true]
F --> G[Show arrows with position-aware state]
G --> H[Include arrow area in popup height]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Hi @zqq-dora. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
62439b9 to
f9f38c0
Compare
Arrows should only appear when the list is scrollable (count > maxVisibleItems). Restore active: view.interactive on the Loader so arrows are not instantiated when the list doesn't scroll, and make spacing/topMargin conditional so no extra space is reserved when arrows are absent.
f9f38c0 to
7187bcf
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, zqq-dora The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
c4aba19
into
linuxdeepin:v25-flowstyle
…dden PR linuxdeepin#728 made ArrowListView's topMargin conditional on itemsView.interactive to avoid extra space when arrows are absent. However, that topMargin was also the only spacing between a search-box header and the menu items. When a menu had a header but no arrows (item count <= maxVisibleItems), the header and the first item were flush together with zero gap. Menu.qml - Add ids to the header and footer Loaders so their loaded state can be checked. - Add Layout.topMargin/bottomMargin on ArrowListView bound to whether the header/footer Loader actually has an item, so the 6px gap only appears when a header or footer is present, and never when absent. - Keep viewLayout spacing at 0 so menus without header/footer get no extra top/bottom padding. ArrowListView.qml - Set anchors.topMargin to 0 unconditionally; the header/list gap is now handled by Menu.qml's Layout.topMargin so the two do not stack. - Split topMargin out of the arrowStrips term in sizedHeight so it is always counted (it is now always 0 here, but kept for clarity). Only the Qt6 (qt6/src/qml/) implementation is changed; Qt5 is left unchanged as v25 ships Qt6 only. 修复带搜索框菜单在无箭头时搜索框与列表项之间缺少间距 PR linuxdeepin#728 将 ArrowListView 的 topMargin 改为按 itemsView.interactive 条件 绑定,无箭头时归零。但该 topMargin 同时也是搜索框 header 与菜单项之间 唯一的间距来源,导致有 header 但无箭头(项数 <= maxVisibleItems)时, 搜索框与第一条菜单项贴在一起。 Menu.qml - 为 header 和 footer Loader 添加 id,以便检测其是否加载了内容。 - 在 ArrowListView 上添加 Layout.topMargin/bottomMargin,绑定到 header/footer Loader 是否有 item,使 6px 间距仅在 header/footer 存在时出现,不存在时不产生多余间距。 - viewLayout spacing 保持 0,无 header/footer 的菜单上下不会多出间距。 ArrowListView.qml - anchors.topMargin 无条件设为 0,header 与列表的间距改由 Menu.qml 的 Layout.topMargin 统一控制,避免两者叠加。 - sizedHeight 中将 topMargin 从 arrowStrips 项中拆出单独计入。 仅修改 Qt6(qt6/src/qml/)实现,Qt5 保持不变,v25 仅使用 Qt6。
…dden PR #728 made ArrowListView's topMargin conditional on itemsView.interactive to avoid extra space when arrows are absent. However, that topMargin was also the only spacing between a search-box header and the menu items. When a menu had a header but no arrows (item count <= maxVisibleItems), the header and the first item were flush together with zero gap. Menu.qml - Add ids to the header and footer Loaders so their loaded state can be checked. - Add Layout.topMargin/bottomMargin on ArrowListView bound to whether the header/footer Loader actually has an item, so the 6px gap only appears when a header or footer is present, and never when absent. - Keep viewLayout spacing at 0 so menus without header/footer get no extra top/bottom padding. ArrowListView.qml - Set anchors.topMargin to 0 unconditionally; the header/list gap is now handled by Menu.qml's Layout.topMargin so the two do not stack. - Split topMargin out of the arrowStrips term in sizedHeight so it is always counted (it is now always 0 here, but kept for clarity). Only the Qt6 (qt6/src/qml/) implementation is changed; Qt5 is left unchanged as v25 ships Qt6 only. 修复带搜索框菜单在无箭头时搜索框与列表项之间缺少间距 PR #728 将 ArrowListView 的 topMargin 改为按 itemsView.interactive 条件 绑定,无箭头时归零。但该 topMargin 同时也是搜索框 header 与菜单项之间 唯一的间距来源,导致有 header 但无箭头(项数 <= maxVisibleItems)时, 搜索框与第一条菜单项贴在一起。 Menu.qml - 为 header 和 footer Loader 添加 id,以便检测其是否加载了内容。 - 在 ArrowListView 上添加 Layout.topMargin/bottomMargin,绑定到 header/footer Loader 是否有 item,使 6px 间距仅在 header/footer 存在时出现,不存在时不产生多余间距。 - viewLayout spacing 保持 0,无 header/footer 的菜单上下不会多出间距。 ArrowListView.qml - anchors.topMargin 无条件设为 0,header 与列表的间距改由 Menu.qml 的 Layout.topMargin 统一控制,避免两者叠加。 - sizedHeight 中将 topMargin 从 arrowStrips 项中拆出单独计入。 仅修改 Qt6(qt6/src/qml/)实现,Qt5 保持不变,v25 仅使用 Qt6。
Background
PR #726 made both navigation arrows in ArrowListView always instantiated and always visible, regardless of the number of items. While this fixes the issue of arrows flickering or missing on first open, it also means that short menus (e.g. 3 items) now show up/down arrows that serve no purpose, since there is nothing to scroll.
The developer pointed out that master already has a
maxVisibleItemsmechanism (default 16) onArrowListView.qmlline 14:Combined with
itemsView.interactive: itemsView.count > maxVisibleItemsandvisible: itemsView.interactiveon the arrow buttons, this mechanism hides the arrows entirely when the item count does not exceedmaxVisibleItems. PR #726 removedvisible: itemsView.interactive, which broke this mechanism.Changes
This PR restores the
maxVisibleItems-based arrow visibility mechanism while keeping PR #726s scroll-position-based grey-out behavior for when arrows are visible:ArrowListViewButton.qml: restore
active: view.interactiveon the Loader. When the list is not scrollable (count ≤ maxVisibleItems), the Loader is inactive — no arrow is instantiated and no layout space is reserved. When scrollable, the arrow is instantiated and itsenabledbinding greys it out at the top/bottom of the list.ArrowListView.qml: make
spacingandtopMarginconditional (itemsView.interactive ? 6 : 0) so no extra spacing is added when arrows are absent. The arrow buttons usestepButtonSize.height(16px) for bothpreferredHeightandminimumHeightso they keep stable dimensions when visible.ArrowListView.qml
sizedHeight: re-add theitemsView.count > maxVisibleItemsconditional branch. When arrows are not shown, the formula does not include the arrow strip height or top margin, preventing the popup from being sized larger than necessary. When arrows are shown, the formula accounts for2 * (stepButtonSize.height + spacing) + topMarginto match the actual layout.Effect
maxVisibleItems(default 16): arrows are hidden, no layout space is reserved, the menu is compact — same as the original master behavior.maxVisibleItems: arrows are always instantiated and visible (no flicker on first open), and grey out based on scroll position — preserving PR #726s core fix.PR #726 让箭头无条件常驻,但项数很少时也显示箭头不合理。研发指出 master 原本有 maxVisibleItems(默认 16)机制控制箭头显隐。
本次修复恢复该机制:
active: view.interactive,Loader 只在可滚动时实例化,不可滚动时不占位spacing和topMargin改为条件绑定(itemsView.interactive ? 6 : 0),无箭头时无多余间距sizedHeight公式加回条件分支,无箭头时不算箭头区高度,避免 popup 尺寸偏大效果:项数 ≤ maxVisibleItems 时不显示箭头、不占空间;超过时箭头常驻并按滚动位置变灰。
Summary by Sourcery
Restore conditional ArrowListView arrow visibility based on whether the list exceeds its maximum visible item count.
Bug Fixes:
Enhancements: