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
2376bfbe
Commit
2376bfbe
authored
Feb 01, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Feb 01, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add aria-controls and remove aria-pressed in sidebar toggle
parent
665bc25d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
1 deletion
+23
-1
Toolbar.tsx
src/annotator/components/Toolbar.tsx
+8
-1
Toolbar-test.js
src/annotator/components/test/Toolbar-test.js
+9
-0
sidebar.tsx
src/annotator/sidebar.tsx
+2
-0
toolbar.tsx
src/annotator/toolbar.tsx
+4
-0
No files found.
src/annotator/components/Toolbar.tsx
View file @
2376bfbe
...
@@ -72,6 +72,12 @@ export type ToolbarProps = {
...
@@ -72,6 +72,12 @@ export type ToolbarProps = {
/** Is the sidebar currently open? */
/** Is the sidebar currently open? */
isSidebarOpen
:
boolean
;
isSidebarOpen
:
boolean
;
/**
* The id attribute for the sidebar container to reference from the sidebar
* toggle's aria-controls attribute
*/
sidebarContainerId
?:
string
;
/**
/**
* Informs which icon to show on the "Create annotation" button and what type
* Informs which icon to show on the "Create annotation" button and what type
* of annotation should be created by the `createAnnotation` callback. The
* of annotation should be created by the `createAnnotation` callback. The
...
@@ -117,6 +123,7 @@ export default function Toolbar({
...
@@ -117,6 +123,7 @@ export default function Toolbar({
closeSidebar
,
closeSidebar
,
createAnnotation
,
createAnnotation
,
isSidebarOpen
,
isSidebarOpen
,
sidebarContainerId
,
newAnnotationType
,
newAnnotationType
,
showHighlights
,
showHighlights
,
toggleHighlights
,
toggleHighlights
,
...
@@ -171,7 +178,7 @@ export default function Toolbar({
...
@@ -171,7 +178,7 @@ export default function Toolbar({
elementRef=
{
toggleSidebarRef
}
elementRef=
{
toggleSidebarRef
}
title=
"Annotation sidebar"
title=
"Annotation sidebar"
expanded=
{
isSidebarOpen
}
expanded=
{
isSidebarOpen
}
pressed=
{
isSidebarOpen
}
aria
-
controls=
{
sidebarContainerId
}
onClick=
{
toggleSidebar
}
onClick=
{
toggleSidebar
}
unstyled
unstyled
>
>
...
...
src/annotator/components/test/Toolbar-test.js
View file @
2376bfbe
...
@@ -100,6 +100,15 @@ describe('Toolbar', () => {
...
@@ -100,6 +100,15 @@ describe('Toolbar', () => {
});
});
});
});
it
(
'sets aria-controls in sidebar toggle button'
,
()
=>
{
const
wrapper
=
createToolbar
({
sidebarContainerId
:
'foo'
});
assert
.
equal
(
findButton
(
wrapper
,
'Annotation sidebar'
).
prop
(
'aria-controls'
),
'foo'
,
);
});
it
(
it
(
'should pass a11y checks'
,
'should pass a11y checks'
,
checkAccessibility
([
checkAccessibility
([
...
...
src/annotator/sidebar.tsx
View file @
2376bfbe
...
@@ -174,6 +174,7 @@ export class Sidebar implements Destroyable {
...
@@ -174,6 +174,7 @@ export class Sidebar implements Destroyable {
this
.
iframeContainer
=
document
.
createElement
(
'div'
);
this
.
iframeContainer
=
document
.
createElement
(
'div'
);
this
.
iframeContainer
.
style
.
display
=
'none'
;
this
.
iframeContainer
.
style
.
display
=
'none'
;
this
.
iframeContainer
.
className
=
'sidebar-container'
;
this
.
iframeContainer
.
className
=
'sidebar-container'
;
this
.
iframeContainer
.
id
=
'sidebar-container'
;
if
(
config
.
theme
===
'clean'
)
{
if
(
config
.
theme
===
'clean'
)
{
this
.
iframeContainer
.
classList
.
add
(
'theme-clean'
);
this
.
iframeContainer
.
classList
.
add
(
'theme-clean'
);
...
@@ -260,6 +261,7 @@ export class Sidebar implements Destroyable {
...
@@ -260,6 +261,7 @@ export class Sidebar implements Destroyable {
// Set up the toolbar on the left edge of the sidebar.
// Set up the toolbar on the left edge of the sidebar.
const
toolbarContainer
=
document
.
createElement
(
'div'
);
const
toolbarContainer
=
document
.
createElement
(
'div'
);
this
.
toolbar
=
new
ToolbarController
(
toolbarContainer
,
{
this
.
toolbar
=
new
ToolbarController
(
toolbarContainer
,
{
sidebarContainerId
:
this
.
iframeContainer
?.
id
,
createAnnotation
:
()
=>
{
createAnnotation
:
()
=>
{
if
(
this
.
_guestRPC
.
length
===
0
)
{
if
(
this
.
_guestRPC
.
length
===
0
)
{
return
;
return
;
...
...
src/annotator/toolbar.tsx
View file @
2376bfbe
...
@@ -7,6 +7,7 @@ export type ToolbarOptions = {
...
@@ -7,6 +7,7 @@ export type ToolbarOptions = {
createAnnotation
:
()
=>
void
;
createAnnotation
:
()
=>
void
;
setSidebarOpen
:
(
open
:
boolean
)
=>
void
;
setSidebarOpen
:
(
open
:
boolean
)
=>
void
;
setHighlightsVisible
:
(
visible
:
boolean
)
=>
void
;
setHighlightsVisible
:
(
visible
:
boolean
)
=>
void
;
sidebarContainerId
?:
string
;
};
};
/**
/**
...
@@ -21,6 +22,7 @@ export class ToolbarController {
...
@@ -21,6 +22,7 @@ export class ToolbarController {
private
_useMinimalControls
:
boolean
;
private
_useMinimalControls
:
boolean
;
private
_highlightsVisible
:
boolean
;
private
_highlightsVisible
:
boolean
;
private
_sidebarOpen
:
boolean
;
private
_sidebarOpen
:
boolean
;
private
_sidebarContainerId
?:
string
;
private
_closeSidebar
:
()
=>
void
;
private
_closeSidebar
:
()
=>
void
;
private
_toggleSidebar
:
()
=>
void
;
private
_toggleSidebar
:
()
=>
void
;
private
_toggleHighlights
:
()
=>
void
;
private
_toggleHighlights
:
()
=>
void
;
...
@@ -38,6 +40,7 @@ export class ToolbarController {
...
@@ -38,6 +40,7 @@ export class ToolbarController {
this
.
_newAnnotationType
=
'note'
;
this
.
_newAnnotationType
=
'note'
;
this
.
_highlightsVisible
=
false
;
this
.
_highlightsVisible
=
false
;
this
.
_sidebarOpen
=
false
;
this
.
_sidebarOpen
=
false
;
this
.
_sidebarContainerId
=
options
.
sidebarContainerId
;
this
.
_closeSidebar
=
()
=>
setSidebarOpen
(
false
);
this
.
_closeSidebar
=
()
=>
setSidebarOpen
(
false
);
this
.
_toggleSidebar
=
()
=>
setSidebarOpen
(
!
this
.
_sidebarOpen
);
this
.
_toggleSidebar
=
()
=>
setSidebarOpen
(
!
this
.
_sidebarOpen
);
...
@@ -124,6 +127,7 @@ export class ToolbarController {
...
@@ -124,6 +127,7 @@ export class ToolbarController {
createAnnotation=
{
this
.
_createAnnotation
}
createAnnotation=
{
this
.
_createAnnotation
}
newAnnotationType=
{
this
.
_newAnnotationType
}
newAnnotationType=
{
this
.
_newAnnotationType
}
isSidebarOpen=
{
this
.
_sidebarOpen
}
isSidebarOpen=
{
this
.
_sidebarOpen
}
sidebarContainerId=
{
this
.
_sidebarContainerId
}
showHighlights=
{
this
.
_highlightsVisible
}
showHighlights=
{
this
.
_highlightsVisible
}
toggleHighlights=
{
this
.
_toggleHighlights
}
toggleHighlights=
{
this
.
_toggleHighlights
}
toggleSidebar=
{
this
.
_toggleSidebar
}
toggleSidebar=
{
this
.
_toggleSidebar
}
...
...
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