fix(components): [pagination] tab enable error if disabled (#8222)

This commit is contained in:
류한경 2022-06-16 01:34:09 +09:00 committed by GitHub
parent 7cb0b45d42
commit eace0489ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 5 deletions

View File

@ -411,5 +411,28 @@ describe('Pagination', () => {
* expect(style.outline).toBeTruthy()
*/
})
test('test tabindex disabled', async () => {
const wrapper = mount({
setup() {
return () => {
return h(Pagination, {
total: 100,
disabled: true,
})
}
},
})
expect(
wrapper.find('.el-pager li:first-child').attributes('tabindex')
).toBe('-1')
await wrapper.setProps({ disabled: false })
expect(
wrapper.find('.el-pager li:first-child').attributes('tabindex')
).toBe('0')
})
})
})

View File

@ -8,7 +8,7 @@
]"
class="number"
:aria-current="currentPage === 1"
tabindex="0"
:tabindex="tabindex"
>
1
</li>
@ -20,7 +20,7 @@
nsIcon.b(),
nsPager.is('disabled', disabled),
]"
tabindex="0"
:tabindex="tabindex"
@mouseenter="onMouseEnter(true)"
@mouseleave="quickPrevHover = false"
@focus="onFocus(true)"
@ -38,7 +38,7 @@
]"
class="number"
:aria-current="currentPage === pager"
tabindex="0"
:tabindex="tabindex"
>
{{ pager }}
</li>
@ -50,7 +50,7 @@
nsIcon.b(),
nsPager.is('disabled', disabled),
]"
tabindex="0"
:tabindex="tabindex"
@mouseenter="onMouseEnter()"
@mouseleave="quickNextHover = false"
@focus="onFocus()"
@ -67,7 +67,7 @@
]"
class="number"
:aria-current="currentPage === pageCount"
tabindex="0"
:tabindex="tabindex"
>
{{ pageCount }}
</li>
@ -128,6 +128,7 @@ const pagers = computed(() => {
}
return array
})
const tabindex = computed(() => (props.disabled ? -1 : 0))
watchEffect(() => {
const halfPagerCount = (props.pagerCount - 1) / 2
showPrevMore.value = false