Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tab focus & keyboard enter event to DrillDown & ViewDrd #802

Merged

Conversation

BrianJVarley
Copy link
Contributor

@BrianJVarley BrianJVarley commented Nov 16, 2023

🔎 a11y changes to improve accessibility of the expand and minimise Decision Table diagram

  • ViewDrd: Remove button outline style override, allow native browser focus style to be applied on focus
  • DrillDown: Change element type to - button to allow keyboard focus and capture ENTER key event to trigger drilldown.

Closes #778 (💡 Discussion in progress & tests needed)

@CLAassistant
Copy link

CLAassistant commented Nov 16, 2023

CLA assistant check
All committers have signed the CLA.

@@ -71,7 +72,7 @@ export default class DrillDown {
addOverlay(element, className) {
const html = domify(`
<div class="drill-down-overlay">
<span class="${className}"></span>
<button class="${className}"></button>
Copy link
Contributor Author

@BrianJVarley BrianJVarley Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the span element doesn't capture ENTER key, I've changed this element to a Button which does capture it. Also removed the outline style override to allow native button outline to be displayed on button focus.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to fix styling here. Also, if the drilldown is not enabled (e.g. for DRD-only viewer), this should remain to be a span as it's not interactive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added type=button because otherwise it's type=submit which is not correct.

Copy link
Contributor Author

@BrianJVarley BrianJVarley Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to fix styling here.

Yeah good point, about the styling added a comment here and a commit -> #802 (comment)

Copy link
Contributor Author

@BrianJVarley BrianJVarley Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if the drilldown is not enabled (e.g. for DRD-only viewer), this should remain to be a span as it's not interactive.

Is there some state or property we can check for "DRD-only viewer" mode? Then we could just add a conditional to render either a span or button within the addOverlay() function:

let html;
    if (isDrdOnlyMode) {
      html = domify(`
      <div class="drill-down-overlay">
        <span type="button" class="${className}"></span>
      </div>
    `);
    } else {
      html = domify(`
      <div class="drill-down-overlay">
        <button type="button" class="${className}"></button>
      </div>
    `);
    }

@barmac barmac self-requested a review November 16, 2023 13:47
// then
expect(drillSpy).to.have.been.calledOnce;

expect(drillSpy).to.have.been.calledWith(overlayEl);
Copy link
Contributor Author

@BrianJVarley BrianJVarley Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on fixing this test, at the moment overlayEl does return the button element, but the drillSpy is not called in test. After the ENTER key event has been triggered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to fix this test too. It looks like in Chrome the synthetic keyboard event for enter doesn't trigger "click" handler, but a trusted keyboard event does. So this won't work:

const event = new KeyboardEvent('keydown', {
  key: 'Enter',
  code: 'Enter',
  which: 13,
  keyCode: 13,
});
mybutton.dispatchEvent(event);

We could add an event handler for Enter (and also Space), or just trust in browser behavior, and leave it untested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah seems fine to skip this test, as the browser will trigger the click event on a button element by default on ENTER key event.

@BrianJVarley BrianJVarley changed the title Add tab focus and keyboard enter event to DrillDown and ViewDrd Buttons Add tab focus & keyboard enter event to DrillDown & ViewDrd Nov 23, 2023
@barmac
Copy link
Member

barmac commented Nov 28, 2023

Hi, thanks for opening this PR and sorry that you had to wait for so long. I will look into this today.

@@ -71,7 +71,7 @@ export default class DrillDown {
addOverlay(element, className) {
const html = domify(`
<div class="drill-down-overlay">
<span class="${className}"></span>
<button type="button" class="${className}"></button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The styling is not quite there yet. I'd rather keep the old look for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barmac can you explain a bit more about the styling? I guess you mean that the previous blue background is missing on the new button element.

Before:
Screenshot 2023-11-28 at 15 20 35

After:

Screenshot 2023-11-28 at 15 19 50

Copy link
Contributor Author

@BrianJVarley BrianJVarley Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a new commit to match the styling that was there previously on the span.
What do you think? __34041ad

Without focus

Screenshot 2023-11-28 at 15 41 50

With focus

Screenshot 2023-11-28 at 15 42 03

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is that if we switch to standard button look, we change the visuals significantly. On the other hand, we need some way to indicate focus.

Copy link
Contributor Author

@BrianJVarley BrianJVarley Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barmac I've pushed another commit so the focus style is more apparent on the drill down button.

Do you see some specific style difference between original and new style as described below?
If so I can try to adjust it further to match the expectation.

For comparison this is the original span style on focus, i.e, no focus focus style applied just span with blue background:

Screenshot 2023-12-04 at 11 27 24

===

Whereas below, this is the latest commit blue button which IMO looks the same as original span style, but with the browser focus style being applied:

Before Focus (default style)

Screenshot 2023-12-04 at 11 34 43

Focused (Dark blue focus style applied by browser)

Screenshot 2023-12-04 at 11 34 51

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it looks better now. I will tweak it a bit and then merge this PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, looking forward to the next release then :)

@BrianJVarley BrianJVarley force-pushed the feat/view-drd-and-drilldown-focus branch from ac556c6 to e3d7e14 Compare December 4, 2023 10:25
@barmac
Copy link
Member

barmac commented Dec 6, 2023

I just noticed that we set the icon DOM element to be a button even if it's not clickable. I will fix that.

@barmac
Copy link
Member

barmac commented Dec 6, 2023

OK I played a bit with CSS, and also made sure that we display span and not button if the drilldown icon is not interactive. Before we merge this, I'd love to gather feedback from the bpmn.io team.

I built a demo website which can be accessed at https://dmn-js-a11y-demo.netlify.app/

Screen.Recording.2023-12-06.at.16.57.36.mov

@marstamm
Copy link
Contributor

marstamm commented Dec 7, 2023

[X-Posting from Slack for transparency]

The Focus has little contrast on the DRD, I think. For the first iteration, this is absolutely fine (still better than what we had before), but we could consider changing it in a follow up

I had a look how Github does it for dark buttons, and they add a white border around the blue outline. Not sure if this is something we want to do
image (5)
image (6)

@barmac
Copy link
Member

barmac commented Dec 7, 2023

I tested this additionally on Firefox, and the focus there is even harder to notice.

What we need to remember is that this PR is just a first step. We can do much more for the accessibility of the tools. For example, the a11y tools don't announce the element which is focused. However, I think it's still better to have some improvement than no-solution as it is without this contribution.

@barmac
Copy link
Member

barmac commented Dec 7, 2023

Increase outline offset looks good on Firefox:

Screen.Recording.2023-12-07.at.13.49.20.mov

and in Chrome:

Screen.Recording.2023-12-07.at.13.50.16.mov

@barmac barmac force-pushed the feat/view-drd-and-drilldown-focus branch from 16ad122 to 35100ba Compare December 7, 2023 12:52
@lmbateman
Copy link

Thank you for raising the accessibility issue, @marstamm . I think there are three ways we could address it:

  1. If we have control over the focus color, we could darken it. Then it would contrast well with both the white background and the button color.
  2. We could also try lightening the button color instead, just on focus. But if we take this route, I think we need to consider it more holistically.
  3. Add an outline-offset to the focus as Martin suggested. This might be difficult because of the lack of space and the small size of the button, but I think reducing the button background area by a pixel on each side would work from a visual perspective (not sure if it's feasible from a technical perspective).

Otherwise, this looks good to me.

@barmac barmac merged commit ab43a42 into bpmn-io:develop Dec 7, 2023
6 of 7 checks passed
@barmac
Copy link
Member

barmac commented Dec 7, 2023

Thanks @BrianJVarley for initiating this and everybody else for feedback! :)

@BrianJVarley
Copy link
Contributor Author

[X-Posting from Slack for transparency]

The Focus has little contrast on the DRD, I think. For the first iteration, this is absolutely fine (still better than what we had before), but we could consider changing it in a follow up

I had a look how Github does it for dark buttons, and they add a white border around the blue outline. Not sure if this is something we want to do image (5) image (6)

@marstamm @barmac I've noticed also using screen reader that the view / hide DRD buttons don't have an aria-label. I think it would improve the accesibility to label these buttons also for example "Show DRD" / "Hide Diagram"

Screenshot 2023-12-11 at 10 57 53

@barmac
Copy link
Member

barmac commented Dec 11, 2023

Thanks for the feedback. Indeed, right now the user does not hear what the button action is. This could be something like View decision table/literal expression of {name}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support DMN diagram accessibility
5 participants