docs: 全文档合规检查与修正 - 代码示例规范/行数准确性/路径一致性/状态同步
This commit is contained in:
@@ -203,12 +203,13 @@
|
||||
|
||||
```tsx
|
||||
"use client"
|
||||
|
||||
import { useAriaLive } from "@/shared/hooks/use-aria-live"
|
||||
|
||||
function MyForm() {
|
||||
function MyForm(): JSX.Element {
|
||||
const { announce, liveRegion } = useAriaLive()
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const handleSubmit = async (): Promise<void> => {
|
||||
const result = await submitAction()
|
||||
if (result.success) {
|
||||
announce("保存成功", { politeness: "polite" })
|
||||
@@ -231,7 +232,7 @@ function MyForm() {
|
||||
```tsx
|
||||
import { useA11yId, describeInput } from "@/shared/lib/a11y"
|
||||
|
||||
function EmailField({ error }: { error?: string }) {
|
||||
function EmailField({ error }: { error?: string }): JSX.Element {
|
||||
const hintId = useA11yId("email-hint")
|
||||
const errorId = useA11yId("email-error")
|
||||
const { ariaDescribedBy, ariaInvalid } = describeInput(
|
||||
@@ -263,7 +264,13 @@ function EmailField({ error }: { error?: string }) {
|
||||
```tsx
|
||||
import { FocusTrap } from "@/shared/components/a11y/focus-trap"
|
||||
|
||||
function CustomModal({ open, onClose, children }) {
|
||||
interface CustomModalProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
function CustomModal({ open, onClose, children }: CustomModalProps): JSX.Element {
|
||||
return (
|
||||
<FocusTrap active={open} restoreFocus>
|
||||
<div role="dialog" aria-modal="true">
|
||||
|
||||
Reference in New Issue
Block a user