1
1
/*
2
- Copyright 2021 The Matrix.org Foundation C.I.C.
2
+ Copyright 2021-2023 The Matrix.org Foundation C.I.C.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
+ import classNames from "classnames" ;
17
18
import React , { ChangeEvent , FormEvent } from "react" ;
18
19
19
20
import Field from "./Field" ;
@@ -22,6 +23,7 @@ import AccessibleButton from "./AccessibleButton";
22
23
import { Tag } from "./Tag" ;
23
24
24
25
interface IProps {
26
+ id ?: string ;
25
27
tags : string [ ] ;
26
28
onAdd : ( tag : string ) => void ;
27
29
onRemove : ( tag : string ) => void ;
@@ -67,9 +69,14 @@ export default class TagComposer extends React.PureComponent<IProps, IState> {
67
69
68
70
public render ( ) : React . ReactNode {
69
71
return (
70
- < div className = "mx_TagComposer" >
72
+ < div
73
+ className = { classNames ( "mx_TagComposer" , {
74
+ mx_TagComposer_disabled : this . props . disabled ,
75
+ } ) }
76
+ >
71
77
< form className = "mx_TagComposer_input" onSubmit = { this . onAdd } >
72
78
< Field
79
+ id = { this . props . id ? this . props . id + "_field" : undefined }
73
80
value = { this . state . newTag }
74
81
onChange = { this . onInputChange }
75
82
label = { this . props . label || _t ( "Keyword" ) }
@@ -81,13 +88,14 @@ export default class TagComposer extends React.PureComponent<IProps, IState> {
81
88
{ _t ( "Add" ) }
82
89
</ AccessibleButton >
83
90
</ form >
84
- < div className = "mx_TagComposer_tags" >
91
+ < div className = "mx_TagComposer_tags" role = "list" >
85
92
{ this . props . tags . map ( ( t , i ) => (
86
93
< Tag
87
94
label = { t }
88
95
key = { t }
89
96
onDeleteClick = { this . onRemove . bind ( this , t ) }
90
97
disabled = { this . props . disabled }
98
+ role = "listitem"
91
99
/>
92
100
) ) }
93
101
</ div >
0 commit comments