Skip to content

fix: handle zero-height content in arrow list view - #759

Closed
18202781743 wants to merge 1 commit into
linuxdeepin:masterfrom
18202781743:master
Closed

18202781743 wants to merge 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743

@18202781743 18202781743 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor
  1. Add hasDelegate property to track if any delegate has been realized
  2. Update sizedHeight logic to treat zero content height as valid when
    delegates exist
  3. Remove temporary viewport fallback in ComboBox popup implicitHeight
  4. Set hasDelegate flag during refreshContentItemWidth iteration

The previous logic assumed contentHeight == 0 meant delegates weren't
realized yet, causing a fallback viewport height. When delegates exist
but measure zero height, this produced incorrect popup sizing. Tracking
delegate realization explicitly distinguishes "not yet realized" from
"realized with zero height".

Influence:

  1. Test ComboBox popup with empty model - should show appropriate
    minimum height
  2. Test ComboBox popup with single item - verify no double-height gap
  3. Test ComboBox popup with items having zero-height delegates
  4. Verify ArrowListView sizing with various item counts
  5. Test popup height recalculation when model changes dynamically
  6. Verify popup renders correctly when delegates become visible

fix: 修复箭头列表视图中零高度内容的处理

  1. 添加 hasDelegate 属性以跟踪是否已实现任何委托
  2. 更新 sizedHeight 逻辑,当存在委托时将零内容高度视为有效
  3. 移除 ComboBox 弹出层 implicitHeight 中的临时视口回退逻辑
  4. 在 refreshContentItemWidth 迭代期间设置 hasDelegate 标志

之前的逻辑假设 contentHeight == 0 意味着委托尚未实现,导致回退到视口高
度。当委托存在但测量高度为零时,这会导致弹出层尺寸错误。显式跟踪委托实现
状态可区分“尚未实现”和“已实现但高度为零”。

Influence:

  1. 测试空模型的 ComboBox 弹出层 - 应显示适当的最小高度
  2. 测试单条目的 ComboBox 弹出层 - 验证无双倍高度间隙
  3. 测试委托高度为零的 ComboBox 弹出层
  4. 验证不同条目数量下 ArrowListView 的尺寸
  5. 测试模型动态变化时弹出层高度的重新计算
  6. 验证委托变为可见时弹出层的正确渲染

Log: Fixed ComboBox popup sizing when content has zero measured height
PMS: BUG-380893

Summary by Sourcery

Correct ArrowListView and ComboBox popup sizing for realized content with zero measured height.

Bug Fixes:

  • Fix ComboBox popup sizing when list delegates have a measured height of zero.

Enhancements:

  • Track delegate realization explicitly so zero-height content is distinguished from unrealized content.
  • Simplify ComboBox popup height calculation by removing the temporary viewport fallback.

1. Add hasDelegate property to track if any delegate has been realized
2. Update sizedHeight logic to treat zero content height as valid when
delegates exist
3. Remove temporary viewport fallback in ComboBox popup implicitHeight
4. Set hasDelegate flag during refreshContentItemWidth iteration

The previous logic assumed contentHeight == 0 meant delegates weren't
realized yet, causing a fallback viewport height. When delegates exist
but measure zero height, this produced incorrect popup sizing. Tracking
delegate realization explicitly distinguishes "not yet realized" from
"realized with zero height".

Influence:
1. Test ComboBox popup with empty model - should show appropriate
minimum height
2. Test ComboBox popup with single item - verify no double-height gap
3. Test ComboBox popup with items having zero-height delegates
4. Verify ArrowListView sizing with various item counts
5. Test popup height recalculation when model changes dynamically
6. Verify popup renders correctly when delegates become visible

fix: 修复箭头列表视图中零高度内容的处理

1. 添加 hasDelegate 属性以跟踪是否已实现任何委托
2. 更新 sizedHeight 逻辑,当存在委托时将零内容高度视为有效
3. 移除 ComboBox 弹出层 implicitHeight 中的临时视口回退逻辑
4. 在 refreshContentItemWidth 迭代期间设置 hasDelegate 标志

之前的逻辑假设 contentHeight == 0 意味着委托尚未实现,导致回退到视口高
度。当委托存在但测量高度为零时,这会导致弹出层尺寸错误。显式跟踪委托实现
状态可区分“尚未实现”和“已实现但高度为零”。

Influence:
1. 测试空模型的 ComboBox 弹出层 - 应显示适当的最小高度
2. 测试单条目的 ComboBox 弹出层 - 验证无双倍高度间隙
3. 测试委托高度为零的 ComboBox 弹出层
4. 验证不同条目数量下 ArrowListView 的尺寸
5. 测试模型动态变化时弹出层高度的重新计算
6. 验证委托变为可见时弹出层的正确渲染

Log: Fixed ComboBox popup sizing when content has zero measured height
PMS: BUG-380893
@18202781743
18202781743 requested review from BLumia and mhduiy November 27, 2026 10:19
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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

@sourcery-ai

sourcery-ai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Track whether a delegate has been realized and use that state to distinguish zero-height content from content that has not yet been measured.

  • qt6/src/qml/ArrowListView.qml L103-109 (+3 small edits)

UI

Remove the ComboBox popup's temporary viewport-height fallback so its implicit height follows the ArrowListView's measured height.

  • qt6/src/qml/ComboBox.qml L175

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@18202781743

Copy link
Copy Markdown
Contributor Author

#721

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="qt6/src/qml/ArrowListView.qml" line_range="27" />
<code_context>
             return 0
-        if (itemsView.contentHeight > 0)
+        // Once a delegate exists, zero is a valid measured content height.
+        if (itemsView.contentHeight > 0 || itemsView.hasDelegate)
             return implicitHeight
         const arrowStrips = itemsView.count > maxVisibleItems
</code_context>
<issue_to_address>
**Nonempty lists stay collapsed**

When a delegate is realized before it has a positive measured height, `itemsView.hasDelegate` makes `ArrowListView.sizedHeight` return `implicitHeight` while `itemsView.contentHeight` is still zero, leaving the ListView without a positive viewport to measure height-dependent or later delegates and keeping the popup collapsed.

Use the provisional viewport estimate until `itemsView.contentHeight` is positive instead of treating `itemsView.hasDelegate` alone as a measured height.
</issue_to_address>

### Comment 2
<location path="qt6/src/qml/ComboBox.qml" line_range="175" />
<code_context>
-        // 60 is a temporary viewport so the list can realize one row and be measured.
-        implicitHeight: (contentItem.sizedHeight > 0 ? contentItem.sizedHeight : 2 * DS.Style.arrowListView.itemHeight)
-                        + topPadding + bottomPadding
+        implicitHeight: contentItem.sizedHeight + topPadding + bottomPadding
         onClosed: control.isInteractingWithContent = false
         Connections {
</code_context>
<issue_to_address>
**Empty popups have no height**

When the ComboBox model is empty and its popup is opened, `contentItem.sizedHeight` is zero, so the `ComboBox` binding sets `implicitHeight` to the popup's default zero vertical padding and overrides the background's implicit minimum; the popup appears collapsed.

Restore a fallback minimum-height estimate when `contentItem.sizedHeight` is zero.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

return 0
if (itemsView.contentHeight > 0)
// Once a delegate exists, zero is a valid measured content height.
if (itemsView.contentHeight > 0 || itemsView.hasDelegate)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Nonempty lists stay collapsed

When a delegate is realized before it has a positive measured height, itemsView.hasDelegate makes ArrowListView.sizedHeight return implicitHeight while itemsView.contentHeight is still zero, leaving the ListView without a positive viewport to measure height-dependent or later delegates and keeping the popup collapsed.

Use the provisional viewport estimate until itemsView.contentHeight is positive instead of treating itemsView.hasDelegate alone as a measured height.

Prompt for AI agents
In `qt6/src/qml/ArrowListView.qml` at line 27:

**Nonempty lists stay collapsed**

When a delegate is realized before it has a positive measured height, `itemsView.hasDelegate` makes `ArrowListView.sizedHeight` return `implicitHeight` while `itemsView.contentHeight` is still zero, leaving the ListView without a positive viewport to measure height-dependent or later delegates and keeping the popup collapsed.

Use the provisional viewport estimate until `itemsView.contentHeight` is positive instead of treating `itemsView.hasDelegate` alone as a measured height.

Comment thread qt6/src/qml/ComboBox.qml
// 60 is a temporary viewport so the list can realize one row and be measured.
implicitHeight: (contentItem.sizedHeight > 0 ? contentItem.sizedHeight : 2 * DS.Style.arrowListView.itemHeight)
+ topPadding + bottomPadding
implicitHeight: contentItem.sizedHeight + topPadding + bottomPadding

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Empty popups have no height

When the ComboBox model is empty and its popup is opened, contentItem.sizedHeight is zero, so the ComboBox binding sets implicitHeight to the popup's default zero vertical padding and overrides the background's implicit minimum; the popup appears collapsed.

Restore a fallback minimum-height estimate when contentItem.sizedHeight is zero.

Prompt for AI agents
In `qt6/src/qml/ComboBox.qml` at line 175:

**Empty popups have no height**

When the ComboBox model is empty and its popup is opened, `contentItem.sizedHeight` is zero, so the `ComboBox` binding sets `implicitHeight` to the popup's default zero vertical padding and overrides the background's implicit minimum; the popup appears collapsed.

Restore a fallback minimum-height estimate when `contentItem.sizedHeight` is zero.

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.

2 participants