Skip to content

Commit 3f0820d

Browse files
authored
Collapse: collapse item can be disabled (ElemeFE#15076)
1 parent 52959d0 commit 3f0820d

File tree

7 files changed

+28
-14
lines changed

7 files changed

+28
-14
lines changed

examples/docs/en-US/collapse.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ Besides using the `title` attribute, you can customize panel title with named sl
126126
### Collapse Item Attributes
127127
| Attribute | Description | Type | Accepted Values | Default |
128128
|---------- |-------------- |---------- |-------------------------------- |-------- |
129-
| name | unique identification of the panel | string/number |||
130-
| title | title of the panel | string |||
129+
| name | unique identification of the panel | string/number |||
130+
| title | title of the panel | string |||
131+
| disabled | disable the collapse item | boolean |||

examples/docs/es/collapse.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,5 @@ Además de usar el atributo `title`, se puede personalizar el título del panel
128128
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
129129
| -------- | ----------------------------- | ------------- | ----------------- | ----------- |
130130
| name | identificador único del panel | string/number |||
131-
| title | título del panel | string |||
131+
| title | título del panel | string |||
132+
| disabled | disable the collapse item | boolean |||

examples/docs/fr-FR/collapse.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ En plus de l'utilisation de l'attribut `title`, vous pouvez configurer les titre
126126
### Attributs de Collapse-Item
127127
| Attribut | Description | Type | Valeurs acceptées | Défaut |
128128
|---------- |-------------- |---------- |-------------------------------- |-------- |
129-
| name | Identifiant unique du panneau. | string/number |||
130-
| title | Titre du panneau. | string |||
129+
| name | Identifiant unique du panneau. | string/number |||
130+
| title | Titre du panneau. | string |||
131+
| disabled | disable the collapse item | boolean |||

examples/docs/zh-CN/collapse.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@
126126
### Collapse Item Attributes
127127
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
128128
|---------- |-------------- |---------- |-------------------------------- |-------- |
129-
| name | 唯一标志符 | string/number |||
130-
| title | 面板标题 | string |||
129+
| name | 唯一标志符 | string/number |||
130+
| title | 面板标题 | string |||
131+
| disabled | 是否禁用 | boolean |||

packages/collapse/src/collapse-item.vue

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
2-
<div class="el-collapse-item" :class="{'is-active': isActive}">
2+
<div class="el-collapse-item"
3+
:class="{'is-active': isActive, 'is-disabled': disabled }">
34
<div
45
role="tab"
56
:aria-expanded="isActive"
@@ -11,7 +12,7 @@
1112
@click="handleHeaderClick"
1213
role="button"
1314
:id="`el-collapse-head-${id}`"
14-
tabindex="0"
15+
:tabindex="disabled ? undefined : 0"
1516
@keyup.space.enter.stop="handleEnterClick"
1617
:class="{
1718
'focusing': focusing,
@@ -65,7 +66,8 @@
6566
},
6667
contentHeight: 0,
6768
focusing: false,
68-
isClick: false
69+
isClick: false,
70+
id: generateId()
6971
};
7072
},
7173
@@ -78,15 +80,13 @@
7880
default() {
7981
return this._uid;
8082
}
81-
}
83+
},
84+
disabled: Boolean
8285
},
8386
8487
computed: {
8588
isActive() {
8689
return this.collapse.activeNames.indexOf(this.name) > -1;
87-
},
88-
id() {
89-
return generateId();
9090
}
9191
},
9292
@@ -101,6 +101,7 @@
101101
}, 50);
102102
},
103103
handleHeaderClick() {
104+
if (this.disabled) return;
104105
this.dispatch('ElCollapse', 'item-click', this);
105106
this.focusing = false;
106107
this.isClick = true;

packages/theme-chalk/src/collapse.scss

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
border-bottom: 1px solid $--collapse-border-color;
88
}
99
@include b(collapse-item) {
10+
@include when(disabled) {
11+
.el-collapse-item__header {
12+
color: $--font-color-disabled-base;
13+
cursor: not-allowed;
14+
}
15+
}
1016
@include e(header) {
1117
display: flex;
1218
align-items: center;

types/collapse-item.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ export declare class ElCollapseItem extends ElementUIComponent {
2020
title: string
2121

2222
$slots: CollapseItemSlots
23+
24+
/** Disable the collapse item */
25+
disabled: boolean
2326
}

0 commit comments

Comments
 (0)