[Glitch] Allow alerts ("toasts") to be announced by assistive tech

Port 4ee21a6c14e97a7f8ccbab22a1de5e91dae4f042 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion 2026-06-08 17:12:56 +02:00 committed by Claire
parent b46babae1e
commit 5c8858acd4
3 changed files with 8 additions and 6 deletions

View File

@ -53,6 +53,7 @@ export const Alert: React.FC<{
className='notification-bar__action' className='notification-bar__action'
onClick={onActionClick} onClick={onActionClick}
type='button' type='button'
aria-hidden='true'
> >
{action} {action}
</button> </button>

View File

@ -11,6 +11,7 @@ import type {
} from 'flavours/glitch/models/alert'; } from 'flavours/glitch/models/alert';
import { useAppSelector, useAppDispatch } from 'flavours/glitch/store'; import { useAppSelector, useAppDispatch } from 'flavours/glitch/store';
import { A11yLiveRegion } from './a11y_live_region';
import { Alert } from './alert'; import { Alert } from './alert';
const formatIfNeeded = ( const formatIfNeeded = (
@ -75,12 +76,8 @@ const TimedAlert: React.FC<{
export const AlertsController: React.FC = () => { export const AlertsController: React.FC = () => {
const alerts = useAppSelector((state) => state.alerts); const alerts = useAppSelector((state) => state.alerts);
if (alerts.length === 0) {
return null;
}
return ( return (
<div className='notification-list'> <A11yLiveRegion className='notification-list'>
{alerts.map((alert, idx) => ( {alerts.map((alert, idx) => (
<TimedAlert <TimedAlert
key={alert.key} key={alert.key}
@ -88,6 +85,6 @@ export const AlertsController: React.FC = () => {
dismissAfter={5000 + idx * 1000} dismissAfter={5000 + idx * 1000}
/> />
))} ))}
</div> </A11yLiveRegion>
); );
}; };

View File

@ -10184,6 +10184,10 @@ noscript {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
&:empty {
display: none;
}
} }
.notification-bar { .notification-bar {