Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
## 2026-07-10 - Accessibility Anti-pattern: Excessive Tab Stops
**Learning:** Adding `tabIndex={0}` to static, non-interactive text badges (like `abbr` or `span`) just to expose their `title` or `aria-label` attributes to keyboard users is an accessibility anti-pattern. It creates excessive tab stops and severely degrades keyboard navigation for users who rely on tab to move through actionable elements.
**Action:** Never add `tabIndex={0}` to non-interactive elements unless they are specifically designed to be focusable for a functional reason. Use proper semantic HTML or let the screen reader read adjacent elements as part of natural navigation.

## 2023-10-27 - Generic Dialog Buttons Need Full Context `aria-label`
**Learning:** Generic action buttons in dialogs (e.g., "Delete", "Duplicate", "Cancel", "Save") can be confusing to screen reader users if they lack context. In `EditTableModal.tsx`, we encountered generic action labels that were improved by explicitly including the target resource name (e.g., table name) in the `aria-label`.
**Action:** When adding generic action buttons like "Save" or "Delete" to modal dialogs, always inject contextual variables (like the item name) into their `aria-label` attribute (e.g., `aria-label={`${editingNode.data.title} μ €μž₯`}`) to ensure an unambiguous screen reader experience.
160 changes: 115 additions & 45 deletions frontend/src/components/modals/EditTableModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import React from "react";
import type { Node } from "@xyflow/react";
import type { TableNodeData } from "../../erd/convert";
import { useDialogAccessibility } from './useDialogAccessibility';
import { useDialogAccessibility } from "./useDialogAccessibility";

interface EditTableModalProps {
isOpen: boolean;
editingNode: Node<TableNodeData> | null;
setEditingNode: React.Dispatch<React.SetStateAction<Node<TableNodeData> | null>>;
setEditingNode: React.Dispatch<
React.SetStateAction<Node<TableNodeData> | null>
>;
setNodes: React.Dispatch<React.SetStateAction<Node<TableNodeData>[]>>;
onEditTableCancel: () => void;
onEditTableSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
Expand All @@ -22,19 +24,43 @@ export function EditTableModal({
onEditTableSubmit,
onDeleteTable,
}: EditTableModalProps) {
const dialogRef = useDialogAccessibility(isOpen && Boolean(editingNode), onEditTableCancel);
const dialogRef = useDialogAccessibility(
isOpen && Boolean(editingNode),
onEditTableCancel,
);

if (!isOpen || !editingNode) return null;

return (
<div className="modalOverlay">
<div className="modal" style={{ width: 800, maxWidth: "90vw", maxHeight: "90vh", display: "flex", flexDirection: "column" }} role="dialog" aria-modal="true" aria-labelledby="edit-table-title" ref={dialogRef} tabIndex={-1}>
<div
className="modal"
style={{
width: 800,
maxWidth: "90vw",
maxHeight: "90vh",
display: "flex",
flexDirection: "column",
}}
role="dialog"
aria-modal="true"
aria-labelledby="edit-table-title"
ref={dialogRef}
tabIndex={-1}
>
<div className="modal__header">
<h3 id="edit-table-title">ν…Œμ΄λΈ” νŽΈμ§‘</h3>
<button type="button" aria-label="λ‹«κΈ°" onClick={onEditTableCancel}>X</button>
<button type="button" aria-label="λ‹«κΈ°" onClick={onEditTableCancel}>
X
</button>
</div>
<div style={{ overflowY: "auto", padding: "0 4px", flex: 1 }}>
<form id="editTableForm" onSubmit={onEditTableSubmit} className="col" style={{ gap: 12 }}>
<form
id="editTableForm"
onSubmit={onEditTableSubmit}
className="col"
style={{ gap: 12 }}
>
<div className="col">
<label htmlFor="editTableTitle">ν…Œμ΄λΈ”λͺ… (schema.table)</label>
<input
Expand All @@ -56,10 +82,18 @@ export function EditTableModal({
</div>

<div className="col" style={{ marginTop: 16 }}>
<div className="row" style={{ justifyContent: "space-between", alignItems: "center", marginBottom: 8 }}>
<div
className="row"
style={{
justifyContent: "space-between",
alignItems: "center",
marginBottom: 8,
}}
>
<h4 style={{ margin: 0 }}>컬럼</h4>
<button
type="button"
aria-label={`${editingNode.data.title} 컬럼 μΆ”κ°€`}
onClick={() => {
setNodes((nds: Node<TableNodeData>[]) =>
nds.map((n: Node<TableNodeData>) => {
Expand All @@ -75,31 +109,31 @@ export function EditTableModal({
data_type: "text",
is_not_null: false,
is_pk: false,
}
]
}
},
],
},
};
}
return n;
})
}),
);
setEditingNode((prev: Node<TableNodeData> | null) => {
if (!prev) return prev;
return {
...prev,
data: {
...prev.data,
columns: [
...prev.data.columns,
{
column_name: `new_col_${Date.now()}`,
data_type: "text",
is_not_null: false,
is_pk: false,
}
]
}
}
if (!prev) return prev;
return {
...prev,
data: {
...prev.data,
columns: [
...prev.data.columns,
{
column_name: `new_col_${Date.now()}`,
data_type: "text",
is_not_null: false,
is_pk: false,
},
],
},
};
});
}}
>
Expand All @@ -109,7 +143,11 @@ export function EditTableModal({

<div className="col" style={{ gap: 8 }}>
{editingNode.data.columns.map((col, idx) => (
<div key={`${col.column_name}-${idx}`} className="row" style={{ gap: 8, alignItems: "center" }}>
<div
key={`${col.column_name}-${idx}`}
className="row"
style={{ gap: 8, alignItems: "center" }}
>
<input
type="text"
name={`col_name_${idx}`}
Expand All @@ -126,15 +164,21 @@ export function EditTableModal({
style={{ flex: 1.5 }}
aria-label="데이터 νƒ€μž…"
/>
<label className="row" style={{ gap: 4, whiteSpace: "nowrap" }}>
<label
className="row"
style={{ gap: 4, whiteSpace: "nowrap" }}
>
<input
type="checkbox"
name={`col_pk_${idx}`}
defaultChecked={col.is_pk}
/>
PK
</label>
<label className="row" style={{ gap: 4, whiteSpace: "nowrap" }}>
<label
className="row"
style={{ gap: 4, whiteSpace: "nowrap" }}
>
<input
type="checkbox"
name={`col_nn_${idx}`}
Expand All @@ -145,30 +189,39 @@ export function EditTableModal({
<button
type="button"
onClick={() => {
if (!window.confirm(`'${col.column_name}' μ»¬λŸΌμ„ μ‚­μ œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?`)) return;
if (
!window.confirm(
`'${col.column_name}' μ»¬λŸΌμ„ μ‚­μ œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?`,
)
)
return;
setNodes((nds: Node<TableNodeData>[]) =>
nds.map((n: Node<TableNodeData>) => {
if (n.id === editingNode.id) {
return {
...n,
data: {
...n.data,
columns: n.data.columns.filter((_, i) => i !== idx)
}
columns: n.data.columns.filter(
(_, i) => i !== idx,
),
},
};
}
return n;
})
}),
);
setEditingNode((prev: Node<TableNodeData> | null) => {
if (!prev) return prev;
return {
...prev,
data: {
...prev.data,
columns: prev.data.columns.filter((_, i) => i !== idx)
}
};
if (!prev) return prev;
return {
...prev,
data: {
...prev.data,
columns: prev.data.columns.filter(
(_, i) => i !== idx,
),
},
};
});
}}
style={{ color: "#b91c1c", padding: "4px 8px" }}
Expand All @@ -183,17 +236,27 @@ export function EditTableModal({
</form>
</div>

<div className="row" style={{ justifyContent: "space-between", marginTop: 16, paddingTop: 16, borderTop: "1px solid #e2e8f0" }}>
<div
className="row"
style={{
justifyContent: "space-between",
marginTop: 16,
paddingTop: 16,
borderTop: "1px solid #e2e8f0",
}}
>
<div className="row" style={{ gap: 8 }}>
<button
type="button"
aria-label={`${editingNode.data.title} ν…Œμ΄λΈ” μ‚­μ œ`}
onClick={onDeleteTable}
style={{ color: "#b91c1c", borderColor: "#fca5a5" }}
>
ν…Œμ΄λΈ” μ‚­μ œ
</button>
<button
type="button"
aria-label={`${editingNode.data.title} 볡제`}
onClick={() => {
const dupId = `${editingNode.id}_copy_${Date.now()}`;
setNodes((nds) => [
Expand Down Expand Up @@ -221,9 +284,16 @@ export function EditTableModal({
</button>
</div>
<div className="row">
<button type="button" onClick={onEditTableCancel}>μ·¨μ†Œ</button>
<button
type="button"
aria-label={`${editingNode.data.title} μ·¨μ†Œ`}
onClick={onEditTableCancel}
>
μ·¨μ†Œ
</button>
<button
type="submit"
aria-label={`${editingNode.data.title} μ €μž₯`}
form="editTableForm"
style={{ background: "#034ea2", color: "#fff" }}
>
Expand Down
Loading