element-plus [Component] [cascader] [Component] [cascader] ElCascader has been disabled but can still be selected

9nvpjoqh  于 6个月前  发布在  其他
关注(0)|答案(3)|浏览(64)

Bug Type: Component

Environment

  • Vue Version: 3.2.37
  • Element Plus Version: 2.2.33
  • Browser / OS: chrome 110.0.5481.105 / window 11
  • Build Tool: Vite

Reproduction

  • el-cascader

Github Repo

Steps to reproduce

<template>
    <el-cascader
      v-model="state.cascaderData"
      :options="options"
      :show-all-levels="false"
      :props="{
checkStrictly: true,
}"
    />
</template>
<script setup lang="ts">
import { reactive } from "vue";
interface State {
cascaderData: string[];
}
const state: State = reactive({
cascaderData: [],
});
const options = [
{
value: "guide",
label: "Guide",
disabled: true,
children: [
{
disabled: true,
value: "disciplines",
label: "Disciplines",
children: [
{
value: "consistency",
label: "Consistency",
},
{
value: "feedback",
label: "Feedback",
},
{
value: "efficiency",
label: "Efficiency",
},
{
value: "controllability",
label: "Controllability",
},
],
},
{
value: "navigation",
label: "Navigation",
disabled: true,
children: [
{
value: "side nav",
label: "Side Navigation",
},
{
value: "top nav",
label: "Top Navigation",
},
],
},
],
},
];
</script>

What is Expected?

Option is disabled and cannot be selected

What is actually happening?

radio is disabled, but click text be selected

Additional comments

gj3fmq9x

gj3fmq9x1#

Set props.checkStrictly = true to make checked state of a node not affects its parent nodes and child nodes, and then you can select any level of options.

Remove checkStrictly: true or set checkStrictly: false may meet expectations.

https://element-plus.org/en-US/component/cascader.html#select-any-level-of-options

playground

ymdaylpp

ymdaylpp2#

I want to set the default data, then select Level 3 option and disable Level 1 and Level 2 option,If I set the attribute, I will not be able to select any option. I think it is bug and not a feature.
like this playground
Set props.checkStrictly = true to make checked state of a node not affects its parent nodes and child nodes, and then you can select any level of options.

Remove checkStrictly: true or set checkStrictly: false may meet expectations.

https://element-plus.org/en-US/component/cascader.html#select-any-level-of-options

playground

ct2axkht

ct2axkht3#

@zhuyue6 I think it might be reasonable. The user has full control over the value.
You are free to modify the value.

Like Select disabled status.
Select disbaled (element-plus playground)
Select disbaled (AntD react) codesandbox
Select disbaled (MUI react) codesandbox

相关问题