Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
63ecb324
Unverified
Commit
63ecb324
authored
Apr 03, 2022
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: missing aria attributes + controls on tabset component
parent
dc5d8dde
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletion
+44
-1
tabset.vue
client/themes/default/components/tabset.vue
+44
-1
No files found.
client/themes/default/components/tabset.vue
View file @
63ecb324
<
template
lang=
"pug"
>
<
template
lang=
"pug"
>
.tabset.elevation-2
.tabset.elevation-2
ul.tabset-tabs(ref='tabs')
ul.tabset-tabs(ref='tabs'
, role='tablist'
)
slot(name='tabs')
slot(name='tabs')
.tabset-content(ref='content')
.tabset-content(ref='content')
slot(name='content')
slot(name='content')
</
template
>
</
template
>
<
script
>
<
script
>
import
{
customAlphabet
}
from
'nanoid/non-secure'
const
nanoid
=
customAlphabet
(
'1234567890abcdef'
,
10
)
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
@@ -23,15 +27,19 @@ export default {
...
@@ -23,15 +27,19 @@ export default {
this
.
$refs
.
tabs
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
this
.
$refs
.
tabs
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
if
(
idx
===
this
.
currentTab
)
{
if
(
idx
===
this
.
currentTab
)
{
node
.
className
=
'is-active'
node
.
className
=
'is-active'
node
.
setAttribute
(
'aria-selected'
,
'true'
)
}
else
{
}
else
{
node
.
className
=
''
node
.
className
=
''
node
.
setAttribute
(
'aria-selected'
,
'false'
)
}
}
})
})
this
.
$refs
.
content
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
this
.
$refs
.
content
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
if
(
idx
===
this
.
currentTab
)
{
if
(
idx
===
this
.
currentTab
)
{
node
.
className
=
'tabset-panel is-active'
node
.
className
=
'tabset-panel is-active'
node
.
removeAttribute
(
'hidden'
)
}
else
{
}
else
{
node
.
className
=
'tabset-panel'
node
.
className
=
'tabset-panel'
node
.
setAttribute
(
'hidden'
,
''
)
}
}
})
})
}
}
...
@@ -53,10 +61,43 @@ export default {
...
@@ -53,10 +61,43 @@ export default {
this
.
setActiveTab
()
this
.
setActiveTab
()
const
tabRefId
=
nanoid
()
this
.
$refs
.
tabs
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
this
.
$refs
.
tabs
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
node
.
setAttribute
(
'id'
,
`
${
tabRefId
}
-
${
idx
}
`
)
node
.
setAttribute
(
'role'
,
'tab'
)
node
.
setAttribute
(
'aria-controls'
,
`
${
tabRefId
}
-
${
idx
}
-tab`
)
node
.
setAttribute
(
'tabindex'
,
'0'
)
node
.
addEventListener
(
'click'
,
ev
=>
{
node
.
addEventListener
(
'click'
,
ev
=>
{
this
.
currentTab
=
[].
indexOf
.
call
(
ev
.
target
.
parentNode
.
children
,
ev
.
target
)
this
.
currentTab
=
[].
indexOf
.
call
(
ev
.
target
.
parentNode
.
children
,
ev
.
target
)
})
})
node
.
addEventListener
(
'keydown'
,
ev
=>
{
if
(
ev
.
key
===
'ArrowLeft'
&&
idx
>
0
)
{
this
.
currentTab
=
idx
-
1
this
.
$refs
.
tabs
.
childNodes
[
idx
-
1
].
focus
()
}
else
if
(
ev
.
key
===
'ArrowRight'
&&
idx
<
this
.
$refs
.
tabs
.
childNodes
.
length
-
1
)
{
this
.
currentTab
=
idx
+
1
this
.
$refs
.
tabs
.
childNodes
[
idx
+
1
].
focus
()
}
else
if
(
ev
.
key
===
'Enter'
||
ev
.
key
===
' '
)
{
this
.
currentTab
=
idx
node
.
focus
()
}
else
if
(
ev
.
key
===
'Home'
)
{
this
.
currentTab
=
0
ev
.
preventDefault
()
ev
.
target
.
parentNode
.
children
[
0
].
focus
()
}
else
if
(
ev
.
key
===
'End'
)
{
this
.
currentTab
=
this
.
$refs
.
tabs
.
childNodes
.
length
-
1
ev
.
preventDefault
()
ev
.
target
.
parentNode
.
children
[
this
.
$refs
.
tabs
.
childNodes
.
length
-
1
].
focus
()
}
})
})
this
.
$refs
.
content
.
childNodes
.
forEach
((
node
,
idx
)
=>
{
node
.
setAttribute
(
'id'
,
`
${
tabRefId
}
-
${
idx
}
-tab`
)
node
.
setAttribute
(
'role'
,
'tabpanel'
)
node
.
setAttribute
(
'aria-labelledby'
,
`
${
tabRefId
}
-
${
idx
}
`
)
node
.
setAttribute
(
'tabindex'
,
'0'
)
})
})
}
}
}
}
...
@@ -106,7 +147,9 @@ export default {
...
@@ -106,7 +147,9 @@ export default {
background-color
:
#FFF
;
background-color
:
#FFF
;
margin-bottom
:
0
;
margin-bottom
:
0
;
padding-bottom
:
17px
;
padding-bottom
:
17px
;
padding-top
:
13px
;
color
:
mc
(
'blue'
,
'700'
);
color
:
mc
(
'blue'
,
'700'
);
border-top
:
3px
solid
mc
(
'blue'
,
'700'
);
@at-root
.theme--dark
&
{
@at-root
.theme--dark
&
{
background-color
:
#292929
;
background-color
:
#292929
;
...
...
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