Skip to content

[Component] [config-provider] ConfigProvider ignores zIndex set to 0 #24330

@guozi9999

Description

@guozi9999

Bug Type: Component

Environment

  • Vue Version: 3.6.0-beta.12
  • Element Plus Version: 2.14.0
  • Browser / OS: UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0
  • Build Tool: Vite

Reproduction

Related Component

  • el-config-provider

Reproduction Link

Element Plus Playground

Steps to reproduce

<template>
  <el-config-provider :z-index="0">
    <div v-loading="true" style="width: 240px; height: 120px">
      loading target
    </div>
  </el-config-provider>
</template>

What is Expected?

zIndex={0} should be treated as a valid configured value.

What is actually happening?

Components using global z-index settings start from the default initial z-index, such as 2000, instead of starting from 0.

Additional comments

Cause

packages/components/config-provider/src/hooks/use-global-config.ts uses || when creating the z-index override:

computed(() => config.value?.zIndex || defaultInitialZIndex)

Because 0 is falsy in JavaScript, it is replaced with defaultInitialZIndex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions