Skip to content

fix(tab-bar): fallback safe-area inset for HarmonyOS - #4304

Merged
novlan1 merged 8 commits into
Tencent:developfrom
Darley-Wey:fix/tabbar-safe-area-fallback-4299
Jun 26, 2026
Merged

fix(tab-bar): fallback safe-area inset for HarmonyOS#4304
novlan1 merged 8 commits into
Tencent:developfrom
Darley-Wey:fix/tabbar-safe-area-fallback-4299

Conversation

@Darley-Wey

@Darley-Wey Darley-Wey commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

fix: #4299

💡 需求背景和解决方案

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-miniprogram

  • fix(tab-bar): 修复 HarmonyOS 的安全区域内边距

@tdesign/uniapp

@tdesign/uniapp-chat

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

Read window safe area and expose a css var fallback for env in TabBar.
This keeps bottom inset working on HarmonyOS Skyline devices. Closes Tencent#4299.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 3, 2026 16:05

Copilot AI 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.

Pull request overview

This PR improves TabBar safe-area handling on HarmonyOS (Skyline) by computing a bottom inset from runtime system info, exposing it to styles via a CSS custom property, and routing existing safe-area CSS to use that custom property.

Changes:

  • Compute and cache safeAreaBottomHeight in TabBar using systemInfo.safeArea.
  • Inject --safe-area-inset-bottom into the TabBar root inline style, with a fallback to env(safe-area-inset-bottom).
  • Update TabBar LESS to use var(--safe-area-inset-bottom) instead of env(safe-area-inset-bottom).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/components/tab-bar/tab-bar.wxml Injects a CSS custom property for bottom safe-area inset with an env() fallback.
packages/components/tab-bar/tab-bar.ts Adds safe-area bottom inset calculation and stores it in component data.
packages/components/tab-bar/tab-bar.less Switches safe-area spacing usage to var(--safe-area-inset-bottom).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/components/tab-bar/tab-bar.ts
Comment thread packages/components/tab-bar/tab-bar.wxml Outdated
Move the injected --safe-area-inset-bottom style before style/customStyle
so customStyle remains last in _._style and can still override values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Mar 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/tdesign-miniprogram@4304
npm i https://pkg.pr.new/@tdesign/uniapp@4304
npm i https://pkg.pr.new/@tdesign/uniapp-chat@4304

commit: 49730aa

@tdesign-bot

tdesign-bot commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

TDesign Component Site Preview Open

Component Preview
tdesign-miniprogram 完成
@tdesign-miniprogram/chat 完成
tdesign-uniapp 完成
tdesign-uniapp-chat 完成

@anlyyao

anlyyao commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

@Darley-Wey 辛苦有空处理一下文件冲突~

@Darley-Wey

Copy link
Copy Markdown
Contributor Author

@Darley-Wey 辛苦有空处理一下文件冲突~

已合并最新版本

@novlan1

novlan1 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

你之前漏了safeAreaInsetBottom属性设置的逻辑,我补上了

js 算出 0 后,反而设置了 env
image

@novlan1
novlan1 merged commit 629341b into Tencent:develop Jun 26, 2026
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.

[TabBar] safe-area-inset-bottom在鸿蒙系统skyline环境无效

5 participants