Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/components/tab-bar/tab-bar.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

&--normal&--safe {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
padding-bottom: var(--safe-area-inset-bottom);
}

&--round {
Expand All @@ -41,6 +41,6 @@

&--fixed&--round&--safe {
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
bottom: var(--safe-area-inset-bottom);
}
}
16 changes: 15 additions & 1 deletion packages/components/tab-bar/tab-bar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { wxComponent, SuperComponent, RelationsOptions } from '../common/src/index';
import config from '../common/config';
import props from './props';
import { getRect } from '../common/utils';
import { getRect, systemInfo } from '../common/utils';

const { prefix } = config;
const classPrefix = `${prefix}-tab-bar`;
Expand All @@ -22,6 +22,7 @@ export default class Tabbar extends SuperComponent {
prefix,
classPrefix,
placeholderHeight: 56,
safeAreaBottomHeight: 0,
};

properties = props;
Expand All @@ -40,15 +41,28 @@ export default class Tabbar extends SuperComponent {
'fixed, placeholder'() {
this.setPlaceholderHeight();
},
safeAreaInsetBottom() {
this.setSafeAreaBottomHeight();
},
};

lifetimes = {
ready() {
this.showChildren();
this.setSafeAreaBottomHeight();
},
};

methods = {
setSafeAreaBottomHeight() {
if (!this.properties.safeAreaInsetBottom) return;

wx.nextTick(() => {
const { screenHeight, safeArea } = systemInfo;
const safeAreaBottomHeight = screenHeight - (safeArea?.bottom ?? screenHeight);
this.setData({ safeAreaBottomHeight: Math.max(0, safeAreaBottomHeight) });
});
Comment on lines +57 to +64
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The new safe-area fallback logic (setSafeAreaBottomHeight + CSS variable injection) isn't covered by existing TabBar tests. Since this affects layout across platforms (including the HarmonyOS regression), please add a unit/snapshot test that verifies the rendered style includes --safe-area-inset-bottom and that it uses the pixel value when systemInfo.safeArea.bottom implies a non-zero inset (and falls back to env(safe-area-inset-bottom) when the computed value is 0).

Copilot uses AI. Check for mistakes.
},
setPlaceholderHeight() {
if (!this.properties.fixed || !this.properties.placeholder) return;

Expand Down
2 changes: 1 addition & 1 deletion packages/components/tab-bar/tab-bar.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
style="height: {{ placeholderHeight }}px;"
/>
<view
style="{{_._style(['z-index: ' + zIndex, style, customStyle])}}"
style="{{_._style(['z-index: ' + zIndex, style, customStyle, '--safe-area-inset-bottom: ' + (safeAreaBottomHeight ? safeAreaBottomHeight + 'px' : 'env(safe-area-inset-bottom)')])}}"
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

customStyle is no longer the last entry in the _._style([...]) list, so any user-provided customStyle can no longer reliably override the injected --safe-area-inset-bottom value. Most components keep customStyle last to preserve override precedence (e.g. packages/components/sticky/sticky.wxml:5, packages/components/overlay/overlay.wxml:6). Consider moving the injected CSS variable earlier in the array (e.g. after z-index and before style/customStyle) so customStyle remains last.

Suggested change
style="{{_._style(['z-index: ' + zIndex, style, customStyle, '--safe-area-inset-bottom: ' + (safeAreaBottomHeight ? safeAreaBottomHeight + 'px' : 'env(safe-area-inset-bottom)')])}}"
style="{{_._style(['z-index: ' + zIndex, style, '--safe-area-inset-bottom: ' + (safeAreaBottomHeight ? safeAreaBottomHeight + 'px' : 'env(safe-area-inset-bottom)'), customStyle])}}"

Copilot uses AI. Check for mistakes.
class="{{_.cls(classPrefix, [['border', bordered], ['fixed', fixed], ['safe', safeAreaInsetBottom], shape])}} class {{prefix}}-class"
aria-role="tablist"
>
Expand Down
Loading