Skip to content

fix: ensure video items always appear at top of search results#624

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:release/eagle
Jun 10, 2026
Merged

fix: ensure video items always appear at top of search results#624
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:release/eagle

Conversation

@LiHua000

@LiHua000 LiHua000 commented Jun 10, 2026

Copy link
Copy Markdown

Previously, .videoItems relied on position:absolute + a 50ms setTimeout
margin hack to stay at the top of search results. This caused a race
condition when multiple Items components loaded asynchronously — the
margin could be applied to the wrong element depending on file I/O
completion order across different machines.

Fix by separating video-guide results in the render method so they
always come first in the DOM, and removing position:absolute from
.videoItems to let it flow naturally. This eliminates both the
timing-dependent hack and the fragile className-based DOM query.

log: fix bug

Bug:https://pms.uniontech.com/bug-view-363963.html

@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.

Sorry @LiHua000, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@LiHua000 LiHua000 changed the title fix: remove absolute positioning from search video items for reliable… fix: ensure video items always appear at top of search results Jun 10, 2026
Previously, .videoItems relied on position:absolute + a 50ms setTimeout
margin hack to stay at the top of search results. This caused a race
condition when multiple Items components loaded asynchronously — the
margin could be applied to the wrong element depending on file I/O
completion order across different machines.

Fix by separating video-guide results in the render method so they
always come first in the DOM, and removing position:absolute from
.videoItems to let it flow naturally. This eliminates both the
timing-dependent hack and the fragile className-based DOM query.

Bug: https://pms.uniontech.com/bug-view-363963.html
@LiHua000

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit 7355074 into linuxdeepin:release/eagle Jun 10, 2026
16 of 18 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

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

2 similar comments
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

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

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我对这个代码审查如下:

  1. 语法逻辑方面:
  • 代码整体结构清晰,逻辑合理
  • 移除了useEffect相关的代码,避免了直接操作DOM,这是好的改进
  • 将搜索结果分为videoResults和otherResults两部分,并分别渲染,使代码更清晰
  1. 代码质量方面:
  • 改进了组件的渲染逻辑,将视频结果和其他结果分开处理,提高了代码可读性
  • 移除了直接操作DOM的代码(useEffect中的adjustOtherElements函数),减少了副作用
  • 代码格式规范,缩进和括号匹配正确
  1. 代码性能方面:
  • 移除了useEffect中的setTimeout操作,避免了不必要的DOM操作和重绘
  • 将搜索结果预先分类再渲染,减少了重复判断,提高了渲染效率
  • 移除了绝对定位(position: absolute)的使用,减少了布局计算
  1. 代码安全方面:
  • 移除了直接操作DOM的代码,避免了XSS攻击的风险
  • 使用React的虚拟DOM进行渲染,更加安全可靠
  • 代码中不再有直接修改DOM样式的情况,减少了潜在的安全问题

改进建议:

  1. 可以考虑将videoResults和otherResults的提取逻辑抽取为一个单独的函数,提高代码复用性
  2. 可以添加适当的注释,说明为什么视频结果要优先显示
  3. 考虑添加错误边界处理,以防止渲染过程中出现错误导致整个页面崩溃
  4. 可以考虑添加适当的类型检查,确保传入的数据格式正确
  5. 建议移除console.log调试代码,保持生产环境的代码整洁

总体来说,这次代码改进是积极的,移除了直接操作DOM的代码,提高了代码的可维护性和性能,同时保持了功能的完整性。

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