diff --git a/js/src/carousel.js b/js/src/carousel.js index b7f3b3a7a9..d85082ce57 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -232,11 +232,10 @@ const Carousel = (($) => { } _keydown(event) { - event.preventDefault() - if (/input|textarea/i.test(event.target.tagName)) { return } + event.preventDefault() switch (event.which) { case ARROW_LEFT_KEYCODE: diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 033ccfd6c5..7fc4f45295 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -759,4 +759,36 @@ $(function () { .bootstrapCarousel('prev') assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide') }) + + QUnit.test('should not prevent keydown for inputs and textareas', function (assert) { + assert.expect(2) + var templateHTML = '