Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
a4674beb
Unverified
Commit
a4674beb
authored
May 21, 2020
by
Lyza Gardner
Committed by
GitHub
May 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add annotation counts to `aria-label` for tab selection (#2190)
Co-authored-by:
Kyle Keating
<
kkeating@hypothes.is
>
parent
095bd446
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
selection-tabs.js
src/sidebar/components/selection-tabs.js
+4
-2
selection-tabs-test.js
src/sidebar/components/test/selection-tabs-test.js
+19
-5
No files found.
src/sidebar/components/selection-tabs.js
View file @
a4674beb
...
@@ -27,6 +27,8 @@ function Tab({
...
@@ -27,6 +27,8 @@ function Tab({
}
}
};
};
const
title
=
count
>
0
?
`
${
label
}
(
${
count
}
available)`
:
label
;
return
(
return
(
<
button
<
button
className
=
{
classnames
(
'selection-tabs__type'
,
{
className
=
{
classnames
(
'selection-tabs__type'
,
{
...
@@ -39,8 +41,8 @@ function Tab({
...
@@ -39,8 +41,8 @@ function Tab({
onMouseDown
=
{
selectTab
}
onMouseDown
=
{
selectTab
}
role
=
"tab"
role
=
"tab"
tabIndex
=
"0"
tabIndex
=
"0"
title
=
{
label
}
title
=
{
title
}
aria
-
label
=
{
label
}
aria
-
label
=
{
title
}
aria
-
selected
=
{
isSelected
.
toString
()}
aria
-
selected
=
{
isSelected
.
toString
()}
>
>
{
children
}
{
children
}
...
...
src/sidebar/components/test/selection-tabs-test.js
View file @
a4674beb
...
@@ -106,18 +106,32 @@ describe('SelectionTabs', function () {
...
@@ -106,18 +106,32 @@ describe('SelectionTabs', function () {
assert
.
equal
(
tabs
.
length
,
2
);
assert
.
equal
(
tabs
.
length
,
2
);
});
});
it
(
'should render `title` and `aria-label` attributes for tab buttons'
,
()
=>
{
it
(
'should render `title` and `aria-label` attributes for tab buttons
, with counts
'
,
()
=>
{
fakeStore
.
orphanCount
.
returns
(
1
);
fakeStore
.
orphanCount
.
returns
(
1
);
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
const
tabs
=
wrapper
.
find
(
'button'
);
const
tabs
=
wrapper
.
find
(
'button'
);
assert
.
equal
(
tabs
.
at
(
0
).
prop
(
'aria-label'
),
'Annotations'
);
assert
.
equal
(
assert
.
equal
(
tabs
.
at
(
0
).
prop
(
'title'
),
'Annotations'
);
tabs
.
at
(
0
).
prop
(
'aria-label'
),
'Annotations (123 available)'
);
assert
.
equal
(
tabs
.
at
(
0
).
prop
(
'title'
),
'Annotations (123 available)'
);
assert
.
equal
(
tabs
.
at
(
1
).
prop
(
'aria-label'
),
'Page notes (456 available)'
);
assert
.
equal
(
tabs
.
at
(
1
).
prop
(
'title'
),
'Page notes (456 available)'
);
assert
.
equal
(
tabs
.
at
(
2
).
prop
(
'aria-label'
),
'Orphans (1 available)'
);
assert
.
equal
(
tabs
.
at
(
2
).
prop
(
'title'
),
'Orphans (1 available)'
);
});
it
(
'should not render count in `title` and `aria-label` for page notes tab if there are no page notes'
,
()
=>
{
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
const
tabs
=
wrapper
.
find
(
'button'
);
assert
.
equal
(
tabs
.
at
(
1
).
prop
(
'aria-label'
),
'Page notes'
);
assert
.
equal
(
tabs
.
at
(
1
).
prop
(
'aria-label'
),
'Page notes'
);
assert
.
equal
(
tabs
.
at
(
1
).
prop
(
'title'
),
'Page notes'
);
assert
.
equal
(
tabs
.
at
(
1
).
prop
(
'title'
),
'Page notes'
);
assert
.
equal
(
tabs
.
at
(
2
).
prop
(
'aria-label'
),
'Orphans'
);
assert
.
equal
(
tabs
.
at
(
2
).
prop
(
'title'
),
'Orphans'
);
});
});
it
(
'should show the clean theme when settings contains the clean theme option'
,
function
()
{
it
(
'should show the clean theme when settings contains the clean theme option'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment