Skip to content

Commit

Permalink
feat: make drilldown buttons navigable via keyboard
Browse files Browse the repository at this point in the history
Related to #778

---------

Co-authored-by: Maciej Barelkowski <[email protected]>
  • Loading branch information
BrianJVarley and barmac authored Dec 7, 2023
1 parent ca60f89 commit ab43a42
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@
color: var(--view-drd-button-color);
font-weight: bold;
cursor: pointer;
outline: none;
}

.dmn-decision-table-container .view-drd .view-drd-button:hover {
Expand Down
16 changes: 13 additions & 3 deletions packages/dmn-js-drd/assets/css/dmn-js-drd.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@

.djs-overlay .drill-down-overlay {
font-size: 16px;
background: var(--drill-down-overlay-background-color);
color: var(--drill-down-overlay-color);
text-align: left;
padding: 1px;
}

.djs-overlay .drill-down-overlay > button,
.djs-overlay .drill-down-overlay > span {
display: block;
padding: 2px 4px;
margin: 0;
border: none;
border-radius: 1px;
padding: 0 2px;
background: var(--drill-down-overlay-background-color);
color: var(--drill-down-overlay-color);
font-size: inherit;
outline-offset: 2px;
}

.dmn-definitions {
Expand Down
8 changes: 5 additions & 3 deletions packages/dmn-js-drd/src/features/drill-down/DrillDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ export default class DrillDown {
* CSS class that will be added to overlay in order to display icon.
*/
addOverlay(element, className) {
const enabled = this._config.enabled !== false;

const html = domify(`
<div class="drill-down-overlay">
<span class="${className}"></span>
${ enabled ? `<button type="button" class="${className}"></button>` :
`<span class="${className}"></span>`}
</div>
`);

Expand All @@ -84,9 +87,8 @@ export default class DrillDown {
});

// TODO(nikku): can we remove renamed to drillDown.enabled
if (this._config.enabled !== false) {
if (enabled) {
domClasses(html).add('interactive');

this.bindEventListener(element, html, overlayId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
} from 'min-dom';

import {
triggerClick
triggerClick,
triggerFocusIn,
triggerKeyEvent
} from 'dmn-js-shared/test/util/EventUtil';

var diagramXML = require('./DrillDown.dmn');
Expand Down Expand Up @@ -215,6 +217,7 @@ describe('features - drilldown', function() {

// then
expect(matches(overlayEl, '.interactive')).to.be.false;
expect(query('button', overlayEl)).to.be.null;
expect(iconEl).to.exist;
});

Expand Down Expand Up @@ -252,6 +255,29 @@ describe('features - drilldown', function() {
}
));

// TODO(@barmac): browser emits 'click' event on ENTER key press
// but not for synthetic events
it.skip('on Enter key pressed', inject(
function(eventBus, drillDown, elementRegistry) {

// given
var drillSpy = sinon.spy(drillDown, 'drillDown');

var overlayEl = queryOverlay('Decision_Table');
console.log(overlayEl.innerHTML);

// when
// press ENTER
triggerFocusIn(overlayEl);
triggerKeyEvent(overlayEl, 'keydown', 13);

// then
expect(drillSpy).to.have.been.calledOnce;

expect(drillSpy).to.have.been.calledWith(overlayEl);
}
));

});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
color: var(--view-drd-button-color);
font-weight: bold;
cursor: pointer;
outline: none;
}

.dmn-literal-expression-container .view-drd .view-drd-button:hover {
Expand Down

0 comments on commit ab43a42

Please sign in to comment.