fix: 修复弹出类组件开启 absolute 后在非 Modal 场景下被自动注入 z-index,导致用户 CSS 层级覆盖失效的问题#2221
Merged
Conversation
…(Regression: since 2.0.23)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
弹出类组件(Dropdown、Select、DatePicker 等)开启
absolute属性后,即使不在Modal内,也会被自动注入style="z-index: 1051"。由于 inline style 优先级最高,用户通过 CSS 自定义 z-index 的方式完全失效,且从 v1 升级到 v2 后行为不一致。Regression: since 2.0.23(commit: 5dd2ee0,PR #1856 Modal Drawer TS 重构时将 Context 默认值从
undefined改为{},导致 zIndex 注入逻辑在所有场景下触发)修复方案
将 Modal Context 默认值由
{}(truthy)改回null,使 zIndex 自动注入行为仅在真正处于 Modal 内部时生效,与 v1 行为保持一致。同步修复
Modal/Panel.tsx中<ZProvider value>的 TypeScript 类型错误(boolean不兼容object | null)。变更文件
src/Modal/context.tsx— Context 默认值{}→null,条件判断value &&→value != null &&src/Modal/Panel.tsx—<ZProvider value>→<ZProvider value={{}}>site/pages/documentation/changelog/2.x.x.md— 补充 changelog