Skip to content

fix(ui/sidebar):correct-sidebar-position - #6546

Open
BradleyZhang wants to merge 1 commit into
QuantumNous:mainfrom
BradleyZhang:fix/correct-sidebar-position
Open

fix(ui/sidebar):correct-sidebar-position#6546
BradleyZhang wants to merge 1 commit into
QuantumNous:mainfrom
BradleyZhang:fix/correct-sidebar-position

Conversation

@BradleyZhang

@BradleyZhang BradleyZhang commented Jul 30, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

[!IMPORTANT]

📝 变更描述 / Description

移除 Sidebar 未实际使用的 side/dir props,改为从 DirectionContext 读取 dir 并推导 side

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

修复前
截屏2026-07-30 16 13 01

修复后
截屏2026-07-30 16 13 46

Summary by CodeRabbit

  • Bug Fixes

    • The sidebar now automatically positions itself on the correct side based on the application’s reading direction, including right-to-left layouts.
  • Improvements

    • Simplified sidebar usage by removing the need to manually specify its side or direction (the component derives this automatically).

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Sidebar component derives left or right placement from the application direction context, removing side and dir from its public props.

Changes

Sidebar direction handling

Layer / File(s) Summary
Derive sidebar placement from direction context
web/src/components/ui/sidebar.tsx
Imports useDirection(), narrows the Sidebar props contract, and computes side internally for desktop and mobile rendering.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: calcium-ion

Poem

I’m a bunny with a sidebar bright,
It hops to the proper side.
LTR sends it left with cheer,
RTL brings it right near.
Direction guides each fluffy stride!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific and clearly refers to fixing the sidebar position in the UI.
Linked Issues check ✅ Passed The change reads direction from context and computes sidebar side accordingly, which matches the RTL positioning issue in #6544.
Out of Scope Changes check ✅ Passed The patch is narrowly scoped to sidebar positioning and prop cleanup in the affected component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/components/ui/sidebar.tsx`:
- Around line 179-183: Update the Sidebar props type to omit the inherited dir
attribute from React.ComponentProps<'div'>, while preserving the component’s
existing internal direction handling and all other div props.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 87f6c209-6512-43ef-a6c5-15a672a666c9

📥 Commits

Reviewing files that changed from the base of the PR and between 66ee6b8 and 9d6e022.

📒 Files selected for processing (1)
  • web/src/components/ui/sidebar.tsx

Comment thread web/src/components/ui/sidebar.tsx
@BradleyZhang
BradleyZhang force-pushed the fix/correct-sidebar-position branch from 9d6e022 to c6f8c02 Compare July 30, 2026 09:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
web/src/components/ui/sidebar.tsx (1)

179-183: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Omit the inherited dir prop from Sidebar props.

React.ComponentProps<'div'> still exposes the standard HTML dir attribute, so callers can pass it even though placement is now controlled by useDirection(). Use Omit<React.ComponentProps<'div'>, 'dir'> to enforce the intended public contract. This is the same unresolved issue raised in the previous review.

Suggested fix
-}: React.ComponentProps<'div'> & {
+}: Omit<React.ComponentProps<'div'>, 'dir'> & {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/components/ui/sidebar.tsx` around lines 179 - 183, Update the Sidebar
props type to use Omit<React.ComponentProps<'div'>, 'dir'>, removing the
inherited dir attribute while preserving all other div props and the existing
variant and collapsible options.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@web/src/components/ui/sidebar.tsx`:
- Around line 179-183: Update the Sidebar props type to use
Omit<React.ComponentProps<'div'>, 'dir'>, removing the inherited dir attribute
while preserving all other div props and the existing variant and collapsible
options.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 996d5426-42e0-4b71-9556-aa8a209c6a78

📥 Commits

Reviewing files that changed from the base of the PR and between 9d6e022 and c6f8c02.

📒 Files selected for processing (1)
  • web/src/components/ui/sidebar.tsx

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.

从右到左方向时,Sidebar位置错误

1 participant