🌐 AI搜索 & 代理 主页
Skip to content

Commit 0c2b406

Browse files
authored
fix(b-modal): remove role="document" from .modal-content (#5345)
* fix(mdoal): remove `role="document"` from `.modal-content` amd only set `role="dialog"` when `.modal` is visible * Always leave `role="dialog"` in place
1 parent c5ed437 commit 0c2b406

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/components/modal/modal.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,17 @@ export const BModal = /*#__PURE__*/ Vue.extend({
422422
}
423423
},
424424
computedModalAttrs() {
425+
const { isVisible, ariaLabel } = this
426+
425427
return {
426428
id: this.modalId,
427429
role: 'dialog',
428-
'aria-hidden': this.isVisible ? null : 'true',
429-
'aria-modal': this.isVisible ? 'true' : null,
430-
'aria-label': this.ariaLabel,
430+
'aria-hidden': isVisible ? null : 'true',
431+
'aria-modal': isVisible ? 'true' : null,
432+
'aria-label': ariaLabel,
431433
'aria-labelledby':
432434
this.hideHeader ||
433-
this.ariaLabel ||
435+
ariaLabel ||
434436
// TODO: Rename slot to `title` and deprecate `modal-title`
435437
!(this.hasNormalizedSlot('modal-title') || this.titleHtml || this.title)
436438
? null
@@ -994,7 +996,6 @@ export const BModal = /*#__PURE__*/ Vue.extend({
994996
staticClass: 'modal-content',
995997
class: this.contentClass,
996998
attrs: {
997-
role: 'document',
998999
id: this.modalContentId,
9991000
tabindex: '-1'
10001001
}

src/components/modal/modal.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ describe('modal', () => {
7474
expect($content.exists()).toBe(true)
7575
expect($content.attributes('tabindex')).toBeDefined()
7676
expect($content.attributes('tabindex')).toEqual('-1')
77-
expect($content.attributes('role')).toBeDefined()
78-
expect($content.attributes('role')).toEqual('document')
7977

8078
wrapper.destroy()
8179
})
@@ -158,8 +156,6 @@ describe('modal', () => {
158156
expect($content.exists()).toBe(true)
159157
expect($content.attributes('tabindex')).toBeDefined()
160158
expect($content.attributes('tabindex')).toEqual('-1')
161-
expect($content.attributes('role')).toBeDefined()
162-
expect($content.attributes('role')).toEqual('document')
163159

164160
wrapper.destroy()
165161
})

0 commit comments

Comments
 (0)