-
Notifications
You must be signed in to change notification settings - Fork 338
fix: fix grid width error when grid has scrollbar #3421
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1016,8 +1016,8 @@ const Methods = { | |||||||||||
| let { fit, columnStore, columnChart, isGroup } = this | ||||||||||||
| let tableHeight = bodyEl.offsetHeight | ||||||||||||
| let overflowY = bodyEl.scrollHeight > bodyEl.clientHeight | ||||||||||||
| // 解决缩放时会出现滚动条的问题 | ||||||||||||
| let bodyW = Math.floor(bodyEl.getBoundingClientRect().width) | ||||||||||||
| // 当浏览器缩放时,实际宽度会出现小数点,clientWidth会取整,此处减去1px解决缩放时会出现滚动条的问题 | ||||||||||||
| let bodyW = bodyEl.clientWidth - 1 | ||||||||||||
|
Comment on lines
+1019
to
+1020
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid subtracting a hardcoded pixel; use - // 当浏览器缩放时,实际宽度会出现小数点,clientWidth会取整,此处减去1px解决缩放时会出现滚动条的问题
- let bodyW = bodyEl.clientWidth - 1
+ // 使用 getBoundingClientRect 的宽度取整,避免浏览器缩放带来的分数像素导致滚动条
+ const bRectWidth = bodyEl.getBoundingClientRect().width
+ let bodyW = Math.floor(bRectWidth)📝 Committable suggestion
Suggested change
|
||||||||||||
| let { leftList, rightList } = columnStore | ||||||||||||
|
|
||||||||||||
| // 此处操作很重要,这里会计算所有列的宽度并且计算出表格整体宽度 | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The adjustment of
bodyWtobodyEl.clientWidth - 1is a critical fix to handle fractional pixel widths that can cause scrollbars to appear during browser zoom. This change ensures that the grid width calculation is more accurate and prevents unwanted scrollbars.