Standardize modal focus and keyboard behavior

This commit is contained in:
Shinuwa 2026-10-15 00:03:13 +02:00
parent e87edda5c7
commit 954240adf9
15 changed files with 331 additions and 139 deletions

View file

@ -1,8 +1,8 @@
// Rôle : affiche et gère les onglets d'espaces persistants d'une toolbox.
import { useEffect, useState } from "react";
import { Icon } from "../../components/Icon.jsx";
import { Modal } from "../../components/Modal.jsx";
import { useGroupedReorder } from "../../hooks/useGroupedReorder.js";
import { lockBodyScroll } from "../../utils/bodyScrollLock.js";
import { MAX_TOOLBOX_SPACES } from "./storage/toolboxStorage.js";
import { createToolboxSpace, deleteToolboxSpace, reorderToolboxSpaces } from "./toolboxSpaceUtils.js";
@ -10,24 +10,20 @@ const SPACE_HOVER_DELAY_MS = 600;
function SpaceNameModal({ initialName = "", title, text, onClose }) {
const [name, setName] = useState(initialName);
useEffect(() => lockBodyScroll(), []);
return (
<div className="confirm-modal-root">
<div className="confirm-backdrop nds-modal-backdrop" onClick={() => onClose("")} />
<section className="confirm-modal nds-modal toolbox-space-modal" role="dialog" aria-modal="true" aria-labelledby="toolbox-space-modal-title">
<Modal dialogClassName="confirm-modal nds-modal toolbox-space-modal" labelledBy="toolbox-space-modal-title" onRequestClose={() => onClose("")}>
<header><h2 id="toolbox-space-modal-title">{title}</h2></header>
<form onSubmit={(event) => {
event.preventDefault();
if (name.trim()) onClose(name.trim());
}}>
<label className="field"><span>{text.nameLabel}</span><input className="nds-input" data-size="sm" value={name} onChange={(event) => setName(event.target.value)} autoComplete="off" autoFocus required /></label>
<label className="field"><span>{text.nameLabel}</span><input className="nds-input" data-size="sm" value={name} onChange={(event) => setName(event.target.value)} autoComplete="off" data-modal-initial-focus="" required /></label>
<footer className="nds-modal-footer">
<button className="nds-button" data-size="sm" type="button" onClick={() => onClose("")}>{text.cancelLabel}</button>
<button className="nds-button" data-size="sm" data-variant="primary" type="submit">{text.saveLabel}</button>
</footer>
</form>
</section>
</div>
</Modal>
);
}