Skip to content

feat: add resizable drawer feature #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: antd-5.x
Choose a base branch
from

Conversation

QdabuliuQ
Copy link

@QdabuliuQ QdabuliuQ commented Aug 11, 2025

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

feat: ant-design/ant-design#54597

💡 Background and Solution

add resizable feature to Drawer component
add ResizableLine component to control the size of drawer

📝 Change Log

Language Changelog
🇺🇸 English add resizable feature to Drawer component
🇨🇳 Chinese Drawer 组件添加 resizable 属性

Copy link

coderabbitai bot commented Aug 11, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Aug 11, 2025

@QdabuliuQ is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

}

export interface DrawerStyles {
mask?: React.CSSProperties;
wrapper?: React.CSSProperties;
content?: React.CSSProperties;
resizableLine?: React.CSSProperties;
Copy link
Contributor

Choose a reason for hiding this comment

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

待讨论 - -

@zombieJ, 这个你怎么看,叫 dragger 吗?

image

Comment on lines +31 to +33
onResize?: (size: number) => void;
onResizeStart?: () => void;
onResizeEnd?: () => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

不确定是否需要一开始暴露这么多回调,看看大佬们怎么说~ 也可以说说你的想法

Copy link
Contributor

Choose a reason for hiding this comment

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

参考了 splitter 的设计是吧,功能是好功能~

image

Copy link
Author

Choose a reason for hiding this comment

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

是的嘞,我觉得有必要暴露出去,因为 antd/drawer 组件使用的时候需要监听到 start / end 事件,取消 / 恢复 transition 过渡 antd/drawer 宽度的样式,这样在拖拽的时候可以动态开启和关闭 transition 影响。

@QdabuliuQ
Copy link
Author

上面的问题都调整了,麻烦大佬们再看看~

// Add global mouse event listeners during drag
document.addEventListener('mousemove', handleMouseMove);
document.addEventListener('mouseup', handleMouseUp);
document.body.style.cursor = isHorizontal ? 'col-resize' : 'row-resize';
Copy link
Contributor

Choose a reason for hiding this comment

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

为啥是 body,如果 dom 不在 body 上呢

Copy link
Author

Choose a reason for hiding this comment

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

这里是鼠标按住resizable 组件的后进入isDragging 状态,就给 body 监听鼠标移动和抬起事件,计算 drawer 的宽度的呀;dom 不在 body 也是可以正常计算的哩

Copy link
Contributor

Choose a reason for hiding this comment

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

我说的是 style.cursor,不过好像问题也不大(交互上看起来没啥问题),isDragging false 的时候也卸载了。
我是看 naive,他是 style 样式放在 drawer 里面的

image

Copy link
Author

Choose a reason for hiding this comment

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

get

@thinkasany
Copy link
Contributor

现在这个维护成本会比较大(在antd侧会有很多的冲突),方便到rc-drawer master 上来一个么,可以用 git cherry-pick,这边一般来说还是希望弄到 next 分支上。
image

@QdabuliuQ
Copy link
Author

现在这个维护成本会比较大(在antd侧会有很多的冲突),方便到rc-drawer master 上来一个么,可以用 git cherry-pick,这边一般来说还是希望弄到 next 分支上。 image

好的 我重新弄到 master 里面

@thinkasany
Copy link
Contributor

辛苦了~ 感谢你的贡献,太感谢了。

@QdabuliuQ
Copy link
Author

#528 @thinkasany 新的 pr 合并到 master的~

@thinkasany
Copy link
Contributor

#528 @thinkasany 新的 pr 合并到 master的~

参考一下 bot 的 cr 建议,有的好像是可以考虑的,然后明天帮你问问豆酱~

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