Skip to content

fix(arrowlistview): fix ArrowListView height oscillation and item clipping - #675

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:fix-arrowlistview-height
Sep 1, 2026
Merged

fix(arrowlistview): fix ArrowListView height oscillation and item clipping#675
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:fix-arrowlistview-height

Conversation

@mhduiy

@mhduiy mhduiy commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

Fix two layout problems in ArrowListView (used by Menu and ComboBox popups):

  1. Height oscillation while scrolling — arrow button visibility was bound to
    atYEnd/atYBeginning, but the buttons are children of the same ColumnLayout that
    sizes the ListView, so toggling them changed the list height → scroll range → boundary
    state → infinite feedback loop. Buttons now stay in the layout (greyed out via their
    internal enabled at boundaries) so height stays constant.
  2. Last item clipped — the viewport used the static style itemHeight, but the real
    delegate height (contentHeight / count) can differ, clipping the last visible item.
    Viewport now derives from actual item height.

Also: use implicitHeight for the button layout preferred height, and simplify the
interactive condition.

PMS: BUG-375249

…pping

1. Show arrow buttons constantly when interactive, grey them out via
   internal enabled instead of hiding them, so layout height stays fixed
2. Size the viewport by real item height (contentHeight / count) rather
   than the static style itemHeight, so the last visible item is not clipped
3. Simplify the interactive condition to model.count vs maxVisibleItems
4. Use implicitHeight for the button layout preferred height

Log: Fix ArrowListView height fluctuating while scrolling and the
last item being clipped when actual item height differs from itemHeight
Influence: Lists in menus and ComboBoxes no longer resize during scroll

fix(arrowlistview): 修复 ArrowListView 滚动时高度振荡与末项被裁剪

1. 箭头按钮改为占用布局后通过内部 enabled 置灰,避免隐藏按钮改变高度
2. 视口改用真实项高(contentHeight/count)计算,替换静态 itemHeight,
   使最后一个可见项不被裁剪
3. interactive 改用 count 与 maxVisibleItems 比较
4. 按钮布局期望高度改用 implicitHeight

Log: 修复列表滚动时高度抖动以及实际项高与 itemHeight 不一致时末项被裁剪
PMS: BUG-375249
Influence: 菜单/下拉列表滚动时不再跳动,末项完整显示
Change-Id: I09a7ef250f82eebf20784336301d24789cad99e6
@mhduiy
mhduiy force-pushed the fix-arrowlistview-height branch from 82305a3 to c9054b7 Compare August 31, 2026 09:20

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@mhduiy
mhduiy requested a review from 18202781743 August 31, 2026 09:23
Comment thread qt6/src/qml/ArrowListView.qml
Comment thread qt6/src/qml/ArrowListView.qml
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 95 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 95 分,大于 70 分通过阈值,代码质量符合要求。本次修改有效修复了 ArrowListView 的高度振荡和最后一项裁剪问题,代码逻辑正确,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. qt6/src/qml/ArrowListView.qml:49 - interactive 条件移除了 contentHeight > Window.window.height 检查,当 delegate 高度异常大时可能无法滚动

建议: 对于 Menu/ComboBox 弹出场景,delegate 高度受控,简化是合理的。如需兼容更通用的场景,可考虑保留 contentHeight 溢出检查作为兜底条件


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. qt6/src/qml/ArrowListView.qml:39 - implicitHeight 计算 contentHeight / itemsView.count 缺少注释说明
  2. qt6/src/qml/ArrowListView.qml:30 - stepSize 使用静态 control.itemHeight,与动态 implicitHeight 计算不一致

建议: 在 implicitHeight 计算处添加注释说明 contentHeight / count 是实际 delegate 高度;考虑将 stepSize 也改为基于实际 item 高度(contentHeight / count)以保持一致性


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,implicitHeight 中的除法运算是 O(1) 复杂度,interactive 条件简化后减少了 Window.window 属性查找开销


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: QML UI 组件,无安全敏感操作,无需额外安全加固


💡 改进建议代码示例

// 建议添加注释并统一 stepSize
ListView {
    id: itemsView
    clip: true
    Layout.fillWidth: true
    Layout.fillHeight: true
    // 使用实际 delegate 高度(contentHeight / count)而非静态 itemHeight
    implicitHeight: itemsView.count > 0 ? Math.min(contentHeight, maxVisibleItems * contentHeight / itemsView.count) : 0
    // ...
    interactive: model.count > maxVisibleItems
}

// ArrowListViewButton 中 stepSize 可考虑使用实际 item 高度
P.ArrowListViewButton {
    // ...
    stepSize: itemsView.count > 0 ? (itemsView.contentHeight / itemsView.count) : control.itemHeight
    // ...
}

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mhduiy
mhduiy merged commit d0de769 into linuxdeepin:master Sep 1, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants