From b35d295ad7a9c18740e76716a585fd78acc9bca0 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 19 Nov 2021 15:16:15 +0800 Subject: [PATCH] feat(Sidebar): add role, aria and tabindex for a11y (#9903) --- .../vant/src/sidebar-item/SidebarItem.tsx | 10 +- packages/vant/src/sidebar/Sidebar.tsx | 2 +- .../test/__snapshots__/demo.spec.ts.snap | 111 +++++++++++++----- .../test/__snapshots__/index.spec.tsx.snap | 12 +- .../test/__snapshots__/demo.spec.ts.snap | 94 +++++++++++---- .../test/__snapshots__/index.spec.tsx.snap | 28 +++-- 6 files changed, 192 insertions(+), 65 deletions(-) diff --git a/packages/vant/src/sidebar-item/SidebarItem.tsx b/packages/vant/src/sidebar-item/SidebarItem.tsx index 477389527..3faa0537b 100644 --- a/packages/vant/src/sidebar-item/SidebarItem.tsx +++ b/packages/vant/src/sidebar-item/SidebarItem.tsx @@ -57,11 +57,17 @@ export default defineComponent({ const selected = index.value === parent.getActive(); return ( - + ); }; }, diff --git a/packages/vant/src/sidebar/Sidebar.tsx b/packages/vant/src/sidebar/Sidebar.tsx index 833b7c649..47fb001bf 100644 --- a/packages/vant/src/sidebar/Sidebar.tsx +++ b/packages/vant/src/sidebar/Sidebar.tsx @@ -41,6 +41,6 @@ export default defineComponent({ setActive, }); - return () =>
{slots.default?.()}
; + return () =>
{slots.default?.()}
; }, }); diff --git a/packages/vant/src/sidebar/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/sidebar/test/__snapshots__/demo.spec.ts.snap index 6f3baf230..905f6f890 100644 --- a/packages/vant/src/sidebar/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/sidebar/test/__snapshots__/demo.spec.ts.snap @@ -9,22 +9,36 @@ exports[`should render demo and match snapshot 1`] = `

Basic Usage

-
- +
@@ -35,30 +49,44 @@ exports[`should render demo and match snapshot 1`] = `

Show Badge

-
- +
@@ -69,22 +97,35 @@ exports[`should render demo and match snapshot 1`] = `

Disabled

-
- +
@@ -95,22 +136,36 @@ exports[`should render demo and match snapshot 1`] = `

Change Event

-
- +
diff --git a/packages/vant/src/sidebar/test/__snapshots__/index.spec.tsx.snap b/packages/vant/src/sidebar/test/__snapshots__/index.spec.tsx.snap index eec8e97bd..5048bfa07 100644 --- a/packages/vant/src/sidebar/test/__snapshots__/index.spec.tsx.snap +++ b/packages/vant/src/sidebar/test/__snapshots__/index.spec.tsx.snap @@ -1,11 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should render title slot correctly 1`] = ` -
- + `; diff --git a/packages/vant/src/tree-select/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/tree-select/test/__snapshots__/demo.spec.ts.snap index 01c358217..35bc23628 100644 --- a/packages/vant/src/tree-select/test/__snapshots__/demo.spec.ts.snap +++ b/packages/vant/src/tree-select/test/__snapshots__/demo.spec.ts.snap @@ -5,22 +5,35 @@ exports[`should render demo and match snapshot 1`] = `
-
- +
@@ -44,22 +57,35 @@ exports[`should render demo and match snapshot 1`] = `
-
- +
@@ -85,17 +111,27 @@ exports[`should render demo and match snapshot 1`] = `
-
- +
@@ -110,22 +146,32 @@ exports[`should render demo and match snapshot 1`] = `
-
- +
diff --git a/packages/vant/src/tree-select/test/__snapshots__/index.spec.tsx.snap b/packages/vant/src/tree-select/test/__snapshots__/index.spec.tsx.snap index d303ad1b6..1d4680079 100644 --- a/packages/vant/src/tree-select/test/__snapshots__/index.spec.tsx.snap +++ b/packages/vant/src/tree-select/test/__snapshots__/index.spec.tsx.snap @@ -12,12 +12,18 @@ exports[`should render content slot correctly 1`] = `
-
- +
Custom Content @@ -29,7 +35,9 @@ exports[`should render empty TreeSelect correctly 1`] = `
-
+
@@ -40,15 +48,21 @@ exports[`should render nav badge correctly 1`] = `