From 8662c0b1bb1cb0c08abd745e38a6ac59246962c7 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 12 Aug 2019 15:38:52 +0200 Subject: [PATCH] Implemented the aria-expanded attribute support on the SplitButtonView#arrowView element. --- src/dropdown/button/splitbuttonview.js | 4 +++- tests/dropdown/button/splitbuttonview.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dropdown/button/splitbuttonview.js b/src/dropdown/button/splitbuttonview.js index f8fdf2ba..ca4fd171 100644 --- a/src/dropdown/button/splitbuttonview.js +++ b/src/dropdown/button/splitbuttonview.js @@ -204,13 +204,15 @@ export default class SplitButtonView extends View { */ _createArrowView() { const arrowView = new ButtonView(); + const bind = arrowView.bindTemplate; arrowView.icon = dropdownArrowIcon; arrowView.extendTemplate( { attributes: { class: 'ck-splitbutton__arrow', - 'aria-haspopup': true + 'aria-haspopup': true, + 'aria-expanded': bind.to( 'isOn', value => String( value ) ) } } ); diff --git a/tests/dropdown/button/splitbuttonview.js b/tests/dropdown/button/splitbuttonview.js index 2fcaba5a..29c51336 100644 --- a/tests/dropdown/button/splitbuttonview.js +++ b/tests/dropdown/button/splitbuttonview.js @@ -70,6 +70,14 @@ describe( 'SplitButtonView', () => { expect( view.element.classList.contains( 'ck-splitbutton_open' ) ).to.be.false; } ); + it( 'binds arrowView aria-expanded attribute to #isOn', () => { + view.arrowView.isOn = true; + expect( view.arrowView.element.getAttribute( 'aria-expanded' ) ).to.equal( 'true' ); + + view.arrowView.isOn = false; + expect( view.arrowView.element.getAttribute( 'aria-expanded' ) ).to.equal( 'false' ); + } ); + describe( 'activates keyboard navigation for the toolbar', () => { it( 'so "arrowright" on view#arrowView does nothing', () => { const keyEvtData = {