Skip to content

Commit

Permalink
fix(carousel): disable the next/prev controls when the carousel is sl…
Browse files Browse the repository at this point in the history
…iding (closes #4210) (#4212)
  • Loading branch information
tmorehouse committed Oct 7, 2019
1 parent 7e4f160 commit 64d556d
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions src/components/carousel/carousel.js
Expand Up @@ -498,19 +498,36 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({
// Prev and next controls
let controls = h()
if (this.controls) {
const prevHandler = evt => {
/* istanbul ignore next */
if (!this.isSliding) {
this.handleClick(evt, this.prev)
} else {
evt.preventDefault()
}
}
const nextHandler = evt => {
/* istanbul ignore next */
if (!this.isSliding) {
this.handleClick(evt, this.next)
} else {
evt.preventDefault()
}
}
controls = [
h(
'a',
{
class: ['carousel-control-prev'],
attrs: { href: '#', role: 'button', 'aria-controls': this.safeId('__BV_inner_') },
attrs: {
href: '#',
role: 'button',
'aria-controls': this.safeId('__BV_inner_'),
'aria-disabled': this.isSliding ? 'true' : null
},
on: {
click: evt => {
this.handleClick(evt, this.prev)
},
keydown: evt => {
this.handleClick(evt, this.prev)
}
click: prevHandler,
keydown: prevHandler
}
},
[
Expand All @@ -522,14 +539,15 @@ export const BCarousel = /*#__PURE__*/ Vue.extend({
'a',
{
class: ['carousel-control-next'],
attrs: { href: '#', role: 'button', 'aria-controls': this.safeId('__BV_inner_') },
attrs: {
href: '#',
role: 'button',
'aria-controls': this.safeId('__BV_inner_'),
'aria-disabled': this.isSliding ? 'true' : null
},
on: {
click: evt => {
this.handleClick(evt, this.next)
},
keydown: evt => {
this.handleClick(evt, this.next)
}
click: nextHandler,
keydown: nextHandler
}
},
[
Expand Down

0 comments on commit 64d556d

Please sign in to comment.