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
@@ -1,6 +1,6 @@
.level-mission-info-banner {
display: flex;
gap: 0.5rem;
gap: 1.5rem;
align-items: center;
padding: 0.5rem 1.5rem;
background-color: var(--level-banner-background-colour);
Expand All @@ -19,6 +19,7 @@
margin: 1rem 0;
Copy link
Member

Choose a reason for hiding this comment

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

Need to remove min-width: 10% above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah sorry misssed that bit

font-weight: 800;
font-size: 1.875rem;
white-space: nowrap;
}

.level-mission-info-banner > p {
Expand All @@ -27,7 +28,7 @@
}

.level-mission-info-banner .themed-button {
gap: 0.25rem;
gap: 0.5rem;
height: auto;
padding: 0.75rem 1rem;
white-space: nowrap;
AAloshine-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -39,8 +40,6 @@
box-sizing: border-box;
height: auto;
padding: 0 0.625rem;
border-style: solid;
border-color: var(--action-button-text-colour);
border-radius: 50%;
background-color: var(--action-button-text-colour);
color: var(--action-button-background-colour);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { render, screen, fireEvent } from '@testing-library/react';
import {
render,
screen,
fireEvent,
getDefaultNormalizer,
} from '@testing-library/react';
import { describe, expect, test, vi } from 'vitest';

import { LEVELS } from '@src/Levels';
Expand All @@ -16,8 +21,15 @@ describe('LevelMissionInfoBanner component tests', () => {
/>
);

const banner = screen.getByTestId('banner-info');
const expectedContent = LEVELS[currentLevel].missionInfoShort ?? '';
const expectedContent = LEVELS[currentLevel].missionInfoShort;

if (!expectedContent)
throw new Error(`No missionInfoShort found for level ${currentLevel}`);

const expectedText = getDefaultNormalizer()(
expectedContent.slice(0, expectedContent.indexOf(' <u>'))
);
const banner = screen.getByText(expectedText);
expect(banner).toContainHTML(expectedContent);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function LevelMissionInfoBanner({
<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 ?? '',
}}
Expand Down
Loading