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

306 add a11y eslint package #330

Merged
merged 27 commits into from
Oct 2, 2023
Merged

Conversation

gsproston-scottlogic
Copy link
Contributor

@gsproston-scottlogic gsproston-scottlogic commented Sep 27, 2023

Would be interested in people's thoughts on how the overlay works. Can't make it so it can be clicked off, or for the user to press 'escape' to close without breaking some eslint rules. Could maybe push that work to #319

Also pulled in work from #269 as that uses some nice interactive elements.

Copy link
Contributor

@dhinrichs-scottlogic dhinrichs-scottlogic left a comment

Choose a reason for hiding this comment

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

looks good, the screen overlay will be its own challenge, need to do some research into how to best do that first.

@gsproston-scottlogic gsproston-scottlogic linked an issue Sep 27, 2023 that may be closed by this pull request
@pmarsh-scottlogic
Copy link
Contributor

Looks like most of the work isn't to do with adding the a11y package, and I'm struggling to review the overlay stuff because I don't have the context, or a linked ticket etc. A screenshot would be handy!

@gsproston-scottlogic
Copy link
Contributor Author

Looks like most of the work isn't to do with adding the a11y package, and I'm struggling to review the overlay stuff because I don't have the context, or a linked ticket etc. A screenshot would be handy!

Yeah as I mentioned I pulled in some work from #269 as it uses interactive html elements (which don't set off a11y linting errors) so I'll wait until #318 is approved before merging this.

There is a linked ticket under the 'development' section on the right, it's #306 .

And yes, the overlay now looks like this:

image

It now has an 'x' to close it.

@chriswilty
Copy link
Member

@gsproston-scottlogic Can you please change the base/target branch to the grouped defenses branch, so we can see what is specific to this PR? Thanks. You'll need to merge that branch first anyway, and once that is merged, github will automatically change the base branch to main.

@chriswilty
Copy link
Member

What eslint rules are breaking by using escape-to-close? That's a pretty universal thing (as is clicking outside to close), whereas an X button to close is not so user-friendly.

@gsproston-scottlogic gsproston-scottlogic changed the base branch from dev to 269-group-defences September 28, 2023 08:12
@gsproston-scottlogic
Copy link
Contributor Author

@gsproston-scottlogic Can you please change the base/target branch to the grouped defenses branch, so we can see what is specific to this PR? Thanks. You'll need to merge that branch first anyway, and once that is merged, github will automatically change the base branch to main.

Yes can do! Changed now 👍

@gsproston-scottlogic
Copy link
Contributor Author

gsproston-scottlogic commented Sep 28, 2023

What eslint rules are breaking by using escape-to-close? That's a pretty universal thing (as is clicking outside to close), whereas an X button to close is not so user-friendly.

It's to do with how the current overlay works. There's an outer "handbook-overlay-screen" div which covers the entire screen, and an child "handbook-overlay" div in that which is the actual overlay bit. I had it so both of these divs had click handlers. The parent to close on click, and the child to stop click propagation.

image

The a11y package didn't like that there were click handlers on divs, and same with key press handlers. In the end I copied our current solution to the 'View Documents' overlay, which simply uses an 'x'. I wasn't quite sure how to make this fully accessible 🤔 We do have another ticket #319 for the overlay, so perhaps we could cover it there?

Base automatically changed from 269-group-defences to dev September 28, 2023 08:39
@chriswilty
Copy link
Member

chriswilty commented Sep 28, 2023

The a11y package didn't like that there were click handlers on divs, and same with key press handlers.

@gsproston-scottlogic Yeah that makes sense, as they cannot be focused. The click and keydown handlers would need to be bound to the window, rather than on the div element of the overlay. That can be done in a useEffect (which could also unbind the event handlers on closing the overlay).

Yep, feel free to tackle this in #319 instead.

Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

Mostly looks good, but a few issues I'm going to moan about!

frontend/src/App.css Outdated Show resolved Hide resolved
frontend/src/Theme.css Show resolved Hide resolved
frontend/src/components/ChatBox/ChatBox.tsx Show resolved Hide resolved
frontend/src/components/DocumentViewer/DocumentViewBox.css Outdated Show resolved Hide resolved
<div id="handbook-overlay-screen">
<div id="handbook-overlay">
<button
id="close-button"
Copy link
Member

Choose a reason for hiding this comment

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

Avoid using html id unless you absolutely need to. Ids must be unique in a document.

I see you are using ids to apply styling, when using a classname is the preferred way. Easy to fix: change id to className in your components, and # to . in the css file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just changed ids to classNames here, and in MainHeader.tsx too. There's a bunch of other instances in the code where we can switch to className, maybe all of them. I could raise a refactor ticket for it?

Copy link
Member

@chriswilty chriswilty Oct 2, 2023

Choose a reason for hiding this comment

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

Added #342

frontend/src/components/MainComponent/MainHeader.tsx Outdated Show resolved Hide resolved
Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

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

👍 Looks good

border: none;
border-width: 1px;
border-style: solid;
border-color: transparent;
Copy link
Member

Choose a reason for hiding this comment

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

FYI You can collapse these: border: 1px solid transparent;

<div id="handbook-overlay-screen">
<div id="handbook-overlay">
<button
id="close-button"
Copy link
Member

@chriswilty chriswilty Oct 2, 2023

Choose a reason for hiding this comment

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

Added #342

* aria-labels for handbook and info buttons

* Better label for defence toggle checkbox
@gsproston-scottlogic gsproston-scottlogic merged commit 47f3eac into dev Oct 2, 2023
2 checks passed
@gsproston-scottlogic gsproston-scottlogic deleted the 306-add-a11y-eslint-package branch October 2, 2023 13:08
chriswilty pushed a commit that referenced this pull request Apr 8, 2024
* Grouped defences

* Better html grouping

* Removed strategy box

* Visually clearer grouping

* Rounded corners on control section

* Added the package

* Fixed issues in ModelConfigurationSlider

* Fixed issues in MainHeader

* Fixed issues in DocumentViewBox

* Removed autofocus for accessibility considerations

* Fixed issues in ApiKeyBox

* Using some rather than find

* Using details html elements

For the collapsible sections in the control panel

* Better html DRY principles

* Fixed issues in DefenceMechanism

* Accessible overlay

* No longer disabling eslint rule for file

* Using border rather than outline for button hover

* Allowing autofocus for chat input

* Better overlay close buttons

* Aria labels for overlay close buttons

* Using class names for styling in handbook overlay

* Handbook icon class name

* 322 wrap handbook image in a button and give aria label (#341)

* aria-labels for handbook and info buttons

* Better label for defence toggle checkbox
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.

add a11y eslint package
4 participants