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
Hide 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
{
normalizeKeyName
,
useElementShouldClose
,
TextInput
,
}
from
'@hypothesis/frontend-shared'
;
import
{
useRef
,
useState
}
from
'preact/hooks'
;
...
...
@@ -270,7 +271,7 @@ function TagEditor({
activeItem
>=
0
?
`
${
tagEditorId
}
-AutocompleteList-item-
${
activeItem
}
`
:
''
;
return
(
<
div
className
=
"
TagEditor
space-y-4"
>
<
div
className
=
"space-y-4"
>
<
TagList
>
{
tagList
.
map
(
tag
=>
{
return
<
TagListItem
key
=
{
tag
}
onRemoveTag
=
{
onRemoveTag
}
tag
=
{
tag
}
/>
;
...
...
@@ -278,7 +279,7 @@ function TagEditor({
<
/TagList
>
<
div
id
=
{
tagEditorId
}
className
=
"TagEditor__combobox-wrapp
er"
data
-
testid
=
"combobox-contain
er"
ref
=
{
closeWrapperRef
}
// Disabled because aria-controls must be attached to the <input> field
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
...
...
@@ -287,13 +288,13 @@ function TagEditor({
aria
-
owns
=
{
`
${
tagEditorId
}
-AutocompleteList`
}
aria
-
haspopup
=
"listbox"
>
<
input
<
TextInput
classes
=
"w-full"
onInput
=
{
handleOnInput
}
onKeyDown
=
{
handleKeyDown
}
onFocus
=
{
handleFocus
}
r
ef
=
{
inputEl
}
inputR
ef
=
{
inputEl
}
placeholder
=
"Add new tags"
className
=
"TagEditor__input"
type
=
"text"
autoComplete
=
"off"
aria
-
autocomplete
=
"list"
...
...
src/sidebar/components/test/TagEditor-test.js
View file @
ae945afb
...
...
@@ -88,10 +88,8 @@ describe('TagEditor', () => {
it
(
'adds appropriate tag values to the elements'
,
()
=>
{
const
wrapper
=
createComponent
();
wrapper
.
find
(
'li'
).
forEach
((
tag
,
i
)
=>
{
assert
.
isTrue
(
tag
.
hasClass
(
'TagEditor__item'
));
assert
.
include
(
tag
.
text
(),
fakeTags
[
i
]);
assert
.
equal
(
tag
.
prop
(
'aria-label'
),
`Tag:
${
fakeTags
[
i
]}
`
);
wrapper
.
find
(
'TagListItem'
).
forEach
((
tag
,
i
)
=>
{
assert
.
equal
(
tag
.
props
().
tag
,
fakeTags
[
i
]);
});
});
...
...
@@ -455,6 +453,7 @@ describe('TagEditor', () => {
});
describe
(
'accessibility attributes and ids'
,
()
=>
{
const
comboboxSelector
=
'[data-testid="combobox-container"]'
;
it
(
'creates multiple <TagEditor> components with unique AutocompleteList `id` props'
,
()
=>
{
const
wrapper1
=
createComponent
();
const
wrapper2
=
createComponent
();
...
...
@@ -469,7 +468,7 @@ describe('TagEditor', () => {
wrapper
.
find
(
'AutocompleteList'
);
assert
.
equal
(
wrapper
.
find
(
'.TagEditor__combobox-wrapper'
).
prop
(
'aria-owns'
),
wrapper
.
find
(
comboboxSelector
).
prop
(
'aria-owns'
),
wrapper
.
find
(
'AutocompleteList'
).
prop
(
'id'
)
);
});
...
...
@@ -479,13 +478,13 @@ describe('TagEditor', () => {
wrapper
.
find
(
'input'
).
instance
().
value
=
'non-empty'
;
// to open list
typeInput
(
wrapper
);
assert
.
equal
(
wrapper
.
find
(
'.TagEditor__combobox-wrapper'
).
prop
(
'aria-expanded'
),
wrapper
.
find
(
comboboxSelector
).
prop
(
'aria-expanded'
),
'true'
);
selectOption
(
wrapper
,
'tag4'
);
wrapper
.
update
();
assert
.
equal
(
wrapper
.
find
(
'.TagEditor__combobox-wrapper'
).
prop
(
'aria-expanded'
),
wrapper
.
find
(
comboboxSelector
).
prop
(
'aria-expanded'
),
'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 @@
@use
'./SelectionTabs'
;
@use
'./SearchInput'
;
@use
'./StyledText'
;
@use
'./TagEditor'
;
@use
'./Thread'
;
@use
'./ThreadCard'
;
@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