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

Make short mission info non-clickable and add button #535 #841

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
gap: 0.5rem;
align-items: center;
padding: 0.5rem 1.5rem;
border: 0.5rem solid transparent;
background-color: var(--level-banner-background-colour);
color: var(--level-banner-text-colour);
text-align: left;
Expand All @@ -26,6 +25,20 @@
font-size: 1rem;
}

.level-mission-info-banner:hover {
background-color: var(--level-banner-background-colour-hover);
.level-mission-info-banner .themed-button {
height: auto;
white-space: nowrap;
AAloshine-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
}

.info-icon {
margin-right: 0.25rem;
AAloshine-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
padding: 0 0.4rem;
border: 0.2rem;
AAloshine-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
border-style: solid;
border-color: var(--action-button-text-colour);
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
border-radius: 50%;
background-color: var(--action-button-text-colour);
color: var(--action-button-background-colour);
font: 1rem serif;
font-weight: bold;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe('LevelMissionInfoBanner component tests', () => {
/>
);

const button = screen.getByRole('button');
const banner = screen.getByTestId('banner-info');
chriswilty marked this conversation as resolved.
Show resolved Hide resolved
const expectedContent = LEVELS[currentLevel].missionInfoShort ?? '';
expect(button).toContainHTML(expectedContent);
expect(banner).toContainHTML(expectedContent);
});

test('fires the openOverlay callback on button click', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LEVELS } from '@src/Levels';
import ThemedButton from '@src/components/ThemedButtons/ThemedButton';
import { LEVEL_NAMES } from '@src/models/level';

import './LevelMissionInfoBanner.css';
Expand All @@ -11,14 +12,21 @@ function LevelMissionInfoBanner({
openOverlay: () => void;
}) {
return (
<button className="level-mission-info-banner" onClick={openOverlay}>
<span className="level-title-area">{`Level ${currentLevel + 1}`}</span>
<span className="level-mission-info-banner">
Copy link
Member

Choose a reason for hiding this comment

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

@dhinrichs-scottlogic Would we be better off using some sort of landmark for this banner, or is it self-explanatory?

I'm wondering if "section" or "complementary" are appropriate. I do realise <section> is a bit controversial...
https://developer.mozilla.org/en-US/blog/aria-accessibility-html-landmark-roles/

Copy link
Contributor

Choose a reason for hiding this comment

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

any semantic element is better than a <span>.
If I follow this flowchart, <article> or <section> seems reasonable

Copy link
Contributor

Choose a reason for hiding this comment

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

landmarks should be used sparingly. If we give this a section, with a header, a text paragraph and a button, I think there's enough context for it without giving it a landmark role, and you already can easily jump to its header. The first rule of aria is: don't use aria if you can avoid it, that's probably true for role declarations, too.
mdn's comedians are putting it aptly here:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

I vote for <article>

Copy link
Member

Choose a reason for hiding this comment

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

Well, that's a possibility. Another is that they are list items within a list inside the chat panel, which itself has role=log:
https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA23
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/log_role

The first link has exactly our use case, plus a working demo. I note once again that Narrator is not announcing "polite" additions to the conversation log, but NVDA is.

Do we want to add this improvement as a separate issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that's our use case, the short mission info doesn't keep a log, or updates, it just contains different text between the levels, which is expected since we are changing context. The same is true for the handbook, control panel, level buttons...
I'd say keep it as simple as possible, use either <section> or <article>, it's at least a little bit more semantic than <span>, but don't add any additional roles or aria for now.

<h2 className="level-title-area">{`Level ${currentLevel + 1}`}</h2>
<p
data-testid="banner-info"
dangerouslySetInnerHTML={{
__html: LEVELS[currentLevel].missionInfoShort ?? '',
}}
></p>
</button>
<ThemedButton onClick={openOverlay}>
<p className="info-icon" aria-hidden="true">
AAloshine-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
i
</p>
Mission Info
</ThemedButton>
</span>
);
}
export default LevelMissionInfoBanner;
Loading