-
Notifications
You must be signed in to change notification settings - Fork 11
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
319 overlay accessibility reworked #391
Conversation
3003a3f
to
5efb0cb
Compare
) : ( | ||
"" | ||
); | ||
) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: if you don't want to render anything, return null or undefined, not empty string.
button { | ||
height: 100%; | ||
width: 100%; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was being applied to all buttons because the css selector is non-specific. Nest styles in top-level classes wherever possible, e.g. this could've been
.export-chat-link > button {
@media (min-width: 768px) { | ||
body { | ||
font-size: 1.125rem; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this was being applied universally to the body, and affecting all our content. Always exercise caution when applying styles to an element without any preceding selectors.
|
||
return () => { | ||
window.removeEventListener("keydown", handleEscape); | ||
window.removeEventListener("click", handleOverlayClick); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gsproston-scottlogic Adding event listeners to the window means we don't get linter warnings about clicks bound to a non-interactive element. We just need to remember to remove them on unmount.
(event: MouseEvent) => { | ||
contentRef.current && | ||
!event.composedPath().includes(contentRef.current) && | ||
closeOverlay(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice modern way to check if an event was triggered by an element or any of its children. If the click was within the content element then we ignore it, else we close the overlay.
5efb0cb
to
8ee06ec
Compare
8ee06ec
to
2d1e524
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - yes we can remove the Tools tab for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Just one small thing from me.
}, []); | ||
|
||
useEffect(() => { | ||
window.addEventListener("keydown", handleEscape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, we shouldn't need to listen for escape presses to close the modal, the dialog element should handle that for us!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, but we need our state to update, and when the dialog closes itself without us intercepting the keypress, we don't get that state update so the code still thinks the dialog is open. And our event listeners are still bound.
This is a good example of a controlled react component. We tell the dialog what state to be in, rather than listening for changes and reacting after the fact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right makes sense!
@heatherlogan-scottlogic I've removed the Tools tab. Note that if we also remove the Mission Info, we'll only have Attacks remaining in the handbook... Just saying! |
ef3d80d
to
c9e6f37
Compare
I remember there being talk about having a handbook section on the architecture of the backend (what LLMs are being used and how), and also a glossary page for certain terms. So we can fill up the handbook with more stuff if we like. |
* Make overlay and handbook accessible * Add click-outside handling to overlay --------- Co-authored-by: Chris Wilton-Magras <[email protected]> Co-authored-by: George Sproston <[email protected]> Co-authored-by: Heather Logan <[email protected]>
Description
Based on work by @heatherlogan-scottlogic and @gsproston-scottlogic, this PR tackles some accessibility issues with the overlay.
Highlights:
Supersedes PR #362
Closes #319