[improvement] Collapse: improve accessibility

This commit is contained in:
陈嘉涵
2019-05-24 11:51:54 +08:00
parent fe7c0c38bf
commit 78fa587575
5 changed files with 31 additions and 22 deletions

View File

@@ -88,9 +88,7 @@ export default sfc({
const { parent } = this;
const name =
parent.accordion && this.currentName === parent.value
? ''
: this.currentName;
parent.accordion && this.currentName === parent.value ? '' : this.currentName;
this.parent.switch(name, !this.expanded);
},
@@ -104,6 +102,8 @@ export default sfc({
},
render(h) {
const { disabled, expanded } = this;
const titleSlots = CELL_SLOTS.reduce((slots, name) => {
if (this.slots(name)) {
slots[name] = () => this.slots(name);
@@ -117,12 +117,12 @@ export default sfc({
const Title = (
<Cell
class={bem('title', {
disabled: this.disabled,
expanded: this.expanded
})}
role="button"
class={bem('title', { disabled, expanded })}
onClick={this.onClick}
scopedSlots={titleSlots}
tabindex={disabled ? -1 : 0}
aria-expanded={String(expanded)}
{...{ props: this.$props }}
/>
);