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
ae945afb
Commit
ae945afb
authored
Apr 05, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Apr 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert TagEditor to tailwind
Use shared `TextInput` component for presentational consistency.
parent
3f45b8c5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
21 deletions
+12
-21
TagEditor.js
src/sidebar/components/TagEditor.js
+6
-5
TagEditor-test.js
src/sidebar/components/test/TagEditor-test.js
+6
-7
TagEditor.scss
src/styles/sidebar/components/TagEditor.scss
+0
-8
_index.scss
src/styles/sidebar/components/_index.scss
+0
-1
No files found.
src/sidebar/components/TagEditor.js
View file @
ae945afb
import
{
import
{
normalizeKeyName
,
normalizeKeyName
,
useElementShouldClose
,
useElementShouldClose
,
TextInput
,
}
from
'@hypothesis/frontend-shared'
;
}
from
'@hypothesis/frontend-shared'
;
import
{
useRef
,
useState
}
from
'preact/hooks'
;
import
{
useRef
,
useState
}
from
'preact/hooks'
;
...
@@ -270,7 +271,7 @@ function TagEditor({
...
@@ -270,7 +271,7 @@ function TagEditor({
activeItem
>=
0
?
`
${
tagEditorId
}
-AutocompleteList-item-
${
activeItem
}
`
:
''
;
activeItem
>=
0
?
`
${
tagEditorId
}
-AutocompleteList-item-
${
activeItem
}
`
:
''
;
return
(
return
(
<
div
className
=
"
TagEditor
space-y-4"
>
<
div
className
=
"space-y-4"
>
<
TagList
>
<
TagList
>
{
tagList
.
map
(
tag
=>
{
{
tagList
.
map
(
tag
=>
{
return
<
TagListItem
key
=
{
tag
}
onRemoveTag
=
{
onRemoveTag
}
tag
=
{
tag
}
/>
;
return
<
TagListItem
key
=
{
tag
}
onRemoveTag
=
{
onRemoveTag
}
tag
=
{
tag
}
/>
;
...
@@ -278,7 +279,7 @@ function TagEditor({
...
@@ -278,7 +279,7 @@ function TagEditor({
<
/TagList
>
<
/TagList
>
<
div
<
div
id
=
{
tagEditorId
}
id
=
{
tagEditorId
}
className
=
"TagEditor__combobox-wrapp
er"
data
-
testid
=
"combobox-contain
er"
ref
=
{
closeWrapperRef
}
ref
=
{
closeWrapperRef
}
// Disabled because aria-controls must be attached to the <input> field
// Disabled because aria-controls must be attached to the <input> field
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
...
@@ -287,13 +288,13 @@ function TagEditor({
...
@@ -287,13 +288,13 @@ function TagEditor({
aria
-
owns
=
{
`
${
tagEditorId
}
-AutocompleteList`
}
aria
-
owns
=
{
`
${
tagEditorId
}
-AutocompleteList`
}
aria
-
haspopup
=
"listbox"
aria
-
haspopup
=
"listbox"
>
>
<
input
<
TextInput
classes
=
"w-full"
onInput
=
{
handleOnInput
}
onInput
=
{
handleOnInput
}
onKeyDown
=
{
handleKeyDown
}
onKeyDown
=
{
handleKeyDown
}
onFocus
=
{
handleFocus
}
onFocus
=
{
handleFocus
}
r
ef
=
{
inputEl
}
inputR
ef
=
{
inputEl
}
placeholder
=
"Add new tags"
placeholder
=
"Add new tags"
className
=
"TagEditor__input"
type
=
"text"
type
=
"text"
autoComplete
=
"off"
autoComplete
=
"off"
aria
-
autocomplete
=
"list"
aria
-
autocomplete
=
"list"
...
...
src/sidebar/components/test/TagEditor-test.js
View file @
ae945afb
...
@@ -88,10 +88,8 @@ describe('TagEditor', () => {
...
@@ -88,10 +88,8 @@ describe('TagEditor', () => {
it
(
'adds appropriate tag values to the elements'
,
()
=>
{
it
(
'adds appropriate tag values to the elements'
,
()
=>
{
const
wrapper
=
createComponent
();
const
wrapper
=
createComponent
();
wrapper
.
find
(
'li'
).
forEach
((
tag
,
i
)
=>
{
wrapper
.
find
(
'TagListItem'
).
forEach
((
tag
,
i
)
=>
{
assert
.
isTrue
(
tag
.
hasClass
(
'TagEditor__item'
));
assert
.
equal
(
tag
.
props
().
tag
,
fakeTags
[
i
]);
assert
.
include
(
tag
.
text
(),
fakeTags
[
i
]);
assert
.
equal
(
tag
.
prop
(
'aria-label'
),
`Tag:
${
fakeTags
[
i
]}
`
);
});
});
});
});
...
@@ -455,6 +453,7 @@ describe('TagEditor', () => {
...
@@ -455,6 +453,7 @@ describe('TagEditor', () => {
});
});
describe
(
'accessibility attributes and ids'
,
()
=>
{
describe
(
'accessibility attributes and ids'
,
()
=>
{
const
comboboxSelector
=
'[data-testid="combobox-container"]'
;
it
(
'creates multiple <TagEditor> components with unique AutocompleteList `id` props'
,
()
=>
{
it
(
'creates multiple <TagEditor> components with unique AutocompleteList `id` props'
,
()
=>
{
const
wrapper1
=
createComponent
();
const
wrapper1
=
createComponent
();
const
wrapper2
=
createComponent
();
const
wrapper2
=
createComponent
();
...
@@ -469,7 +468,7 @@ describe('TagEditor', () => {
...
@@ -469,7 +468,7 @@ describe('TagEditor', () => {
wrapper
.
find
(
'AutocompleteList'
);
wrapper
.
find
(
'AutocompleteList'
);
assert
.
equal
(
assert
.
equal
(
wrapper
.
find
(
'.TagEditor__combobox-wrapper'
).
prop
(
'aria-owns'
),
wrapper
.
find
(
comboboxSelector
).
prop
(
'aria-owns'
),
wrapper
.
find
(
'AutocompleteList'
).
prop
(
'id'
)
wrapper
.
find
(
'AutocompleteList'
).
prop
(
'id'
)
);
);
});
});
...
@@ -479,13 +478,13 @@ describe('TagEditor', () => {
...
@@ -479,13 +478,13 @@ describe('TagEditor', () => {
wrapper
.
find
(
'input'
).
instance
().
value
=
'non-empty'
;
// to open list
wrapper
.
find
(
'input'
).
instance
().
value
=
'non-empty'
;
// to open list
typeInput
(
wrapper
);
typeInput
(
wrapper
);
assert
.
equal
(
assert
.
equal
(
wrapper
.
find
(
'.TagEditor__combobox-wrapper'
).
prop
(
'aria-expanded'
),
wrapper
.
find
(
comboboxSelector
).
prop
(
'aria-expanded'
),
'true'
'true'
);
);
selectOption
(
wrapper
,
'tag4'
);
selectOption
(
wrapper
,
'tag4'
);
wrapper
.
update
();
wrapper
.
update
();
assert
.
equal
(
assert
.
equal
(
wrapper
.
find
(
'.TagEditor__combobox-wrapper'
).
prop
(
'aria-expanded'
),
wrapper
.
find
(
comboboxSelector
).
prop
(
'aria-expanded'
),
'false'
'false'
);
);
});
});
...
...
src/styles/sidebar/components/TagEditor.scss
deleted
100644 → 0
View file @
3f45b8c5
@use
'../../mixins/forms'
;
.TagEditor
{
&
__input
{
@include
forms
.
form-input
;
width
:
100%
;
}
}
src/styles/sidebar/components/_index.scss
View file @
ae945afb
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
@use
'./SelectionTabs'
;
@use
'./SelectionTabs'
;
@use
'./SearchInput'
;
@use
'./SearchInput'
;
@use
'./StyledText'
;
@use
'./StyledText'
;
@use
'./TagEditor'
;
@use
'./Thread'
;
@use
'./Thread'
;
@use
'./ThreadCard'
;
@use
'./ThreadCard'
;
@use
'./ThreadList'
;
@use
'./ThreadList'
;
...
...
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