@@ -6,7 +6,6 @@ import { Combobox } from "@headlessui/react";
66// plane imports
77import { EUserPermissionsLevel , getRandomLabelColor } from "@plane/constants" ;
88import { useTranslation } from "@plane/i18n" ;
9- import { LabelFilledIcon , LabelPropertyIcon } from "@plane/propel/icons" ;
109import type { IIssueLabel } from "@plane/types" ;
1110import { EUserProjectRoles } from "@plane/types" ;
1211// helpers
@@ -86,15 +85,9 @@ export const IssueLabelSelect = observer(function IssueLabelSelect(props: IIssue
8685 const issueLabels = values ?? [ ] ;
8786
8887 const label = (
89- < button
90- type = "button"
91- className = "h-full w-full flex items-center gap-1.5 rounded-lg px-2 py-0.5 bg-layer-transparent-active hover:bg-layer-transparent-hover text-body-xs-regular text-tertiary"
92- >
93- < div className = "flex-shrink-0" >
94- < LabelFilledIcon className = "size-3.5" />
95- </ div >
96- < div className = "flex-shrink-0" > { t ( "label.select" ) } </ div >
97- </ button >
88+ < span className = "size-full flex items-center rounded-sm px-2 py-0.5 bg-layer-transparent hover:bg-layer-transparent-hover text-body-xs-regular text-tertiary" >
89+ { t ( "label.select" ) }
90+ </ span >
9891 ) ;
9992
10093 const searchInputKeyDown = async ( e : React . KeyboardEvent < HTMLInputElement > ) => {
@@ -121,101 +114,149 @@ export const IssueLabelSelect = observer(function IssueLabelSelect(props: IIssue
121114 if ( ! issueId || ! values ) return < > </ > ;
122115
123116 return (
124- < >
125- < Combobox
126- as = "div"
127- className = { `w-auto max-w-full flex-shrink-0 text-left` }
128- value = { issueLabels }
129- onChange = { ( value ) => onSelect ( value ) }
130- multiple
131- >
132- < Combobox . Button as = { Fragment } >
133- < button
134- ref = { setReferenceElement }
135- type = "button"
136- className = "cursor-pointer"
137- onClick = { ( ) => ! projectLabels && fetchLabels ( ) }
138- >
139- { label }
140- </ button >
141- </ Combobox . Button >
142-
143- < Combobox . Options className = "fixed z-10" >
144- < div
145- className = { `z-10 my-1 w-48 whitespace-nowrap rounded-sm border border-strong bg-surface-1 py-2.5 text-11 shadow-raised-200 focus:outline-none` }
146- ref = { setPopperElement }
147- style = { styles . popper }
148- { ...attributes . popper }
149- >
150- < div className = "px-2" >
151- < div className = "flex w-full items-center justify-start rounded-sm border border-subtle bg-surface-2 px-2" >
152- < Search className = "h-3.5 w-3.5 text-tertiary" />
153- < Combobox . Input
154- className = "w-full bg-transparent px-2 py-1 text-11 text-secondary placeholder:text-placeholder focus:outline-none"
155- value = { query }
156- onChange = { ( e ) => setQuery ( e . target . value ) }
157- placeholder = { t ( "common.search.label" ) }
158- displayValue = { ( assigned : any ) => assigned ?. name }
159- onKeyDown = { searchInputKeyDown }
160- tabIndex = { baseTabIndex }
161- />
162- </ div >
117+ < Combobox
118+ as = "div"
119+ className = "size-full flex-shrink-0 text-left"
120+ value = { issueLabels }
121+ onChange = { ( value ) => onSelect ( value ) }
122+ multiple
123+ >
124+ < Combobox . Button as = { Fragment } >
125+ < button
126+ ref = { setReferenceElement }
127+ type = "button"
128+ className = "cursor-pointer size-full"
129+ onClick = { ( ) => ! projectLabels && fetchLabels ( ) }
130+ >
131+ { label }
132+ </ button >
133+ </ Combobox . Button >
134+ < Combobox . Options className = "fixed z-10" >
135+ < div
136+ className = { `z-10 my-1 w-48 whitespace-nowrap rounded-sm border border-strong bg-surface-1 py-2.5 text-11 shadow-raised-200 focus:outline-none` }
137+ ref = { setPopperElement }
138+ style = { styles . popper }
139+ { ...attributes . popper }
140+ >
141+ < div className = "px-2" >
142+ < div className = "flex w-full items-center justify-start rounded-sm border border-subtle bg-surface-2 px-2" >
143+ < Search className = "h-3.5 w-3.5 text-tertiary" />
144+ < Combobox . Input
145+ className = "w-full bg-transparent px-2 py-1 text-11 text-secondary placeholder:text-placeholder focus:outline-none"
146+ value = { query }
147+ onChange = { ( e ) => setQuery ( e . target . value ) }
148+ placeholder = { t ( "common.search.label" ) }
149+ displayValue = { ( assigned : any ) => assigned ?. name }
150+ onKeyDown = { searchInputKeyDown }
151+ tabIndex = { baseTabIndex }
152+ />
163153 </ div >
164- < div className = { `vertical-scrollbar scrollbar-sm mt-2 max-h-48 space-y-1 overflow-y-scroll px-2 pr-0` } >
165- { isLoading ? (
166- < p className = "text-center text-secondary" > { t ( "common.loading" ) } </ p >
167- ) : filteredOptions . length > 0 ? (
168- filteredOptions . map ( ( option ) => (
169- < Combobox . Option
170- key = { option . value }
171- value = { option . value }
172- className = { ( { selected } ) =>
173- `flex cursor-pointer select-none items-center justify-between gap-2 truncate rounded-sm px-1 py-1.5 hover:bg-layer-1 ${
174- selected ? "text-primary" : "text-secondary"
175- } `
176- }
177- >
178- { ( { selected } ) => (
179- < >
180- { option . content }
181- { selected && (
182- < div className = "flex-shrink-0" >
183- < Check className = { `h-3.5 w-3.5` } />
184- </ div >
185- ) }
186- </ >
187- ) }
188- </ Combobox . Option >
189- ) )
190- ) : submitting ? (
191- < Loader className = "spin h-3.5 w-3.5" />
192- ) : canCreateLabel ? (
154+ </ div >
155+ < div className = { `vertical-scrollbar scrollbar-sm mt-2 max-h-48 space-y-1 overflow-y-scroll px-2 pr-0` } >
156+ { isLoading ? (
157+ < p className = "text-center text-secondary" > { t ( "common.loading" ) } </ p >
158+ ) : filteredOptions . length > 0 ? (
159+ filteredOptions . map ( ( option ) => (
193160 < Combobox . Option
194- value = { query }
195- onClick = { ( e ) => {
196- e . preventDefault ( ) ;
197- e . stopPropagation ( ) ;
198- if ( ! query . length ) return ;
199- handleAddLabel ( query ) ;
200- } }
201- className = { `text-left text-secondary ${ query . length ? "cursor-pointer" : "cursor-default" } ` }
161+ key = { option . value }
162+ value = { option . value }
163+ className = { ( { selected } ) =>
164+ `flex cursor-pointer select-none items-center justify-between gap-2 truncate rounded-sm px-1 py-1.5 hover:bg-layer-1 ${
165+ selected ? "text-primary" : "text-secondary"
166+ } `
167+ }
202168 >
203- { query . length ? (
169+ { ( { selected } ) => (
204170 < >
205- { /* TODO: Translate here */ } + Add < span className = "text-primary" > "{ query } "</ span > to
206- labels
171+ { option . content }
172+ { selected && (
173+ < div className = "flex-shrink-0" >
174+ < Check className = { `h-3.5 w-3.5` } />
175+ </ div >
176+ ) }
207177 </ >
208- ) : (
209- t ( "label.create.type" )
210178 ) }
211179 </ Combobox . Option >
180+ ) )
181+ ) : submitting ? (
182+ < Loader className = "spin h-3.5 w-3.5" />
183+ ) : canCreateLabel ? (
184+ < Combobox . Option
185+ value = { query }
186+ onClick = { ( e ) => {
187+ e . preventDefault ( ) ;
188+ e . stopPropagation ( ) ;
189+ if ( ! query . length ) return ;
190+ handleAddLabel ( query ) ;
191+ } }
192+ className = { `text-left text-secondary ${ query . length ? "cursor-pointer" : "cursor-default" } ` }
193+ >
194+ { query . length ? (
195+ < >
196+ { /* TODO: Translate here */ } + Add < span className = "text-primary" > "{ query } "</ span > to
197+ labels
198+ </ >
199+ ) : (
200+ t ( "label.create.type" )
201+ ) }
202+ </ Combobox . Option >
203+ ) : (
204+ < p className = "text-left text-secondary " > { t ( "common.search.no_matching_results" ) } </ p >
205+ ) }
206+ </ div >
207+ </ div >
208+ < div className = { `vertical-scrollbar scrollbar-sm mt-2 max-h-48 space-y-1 overflow-y-scroll px-2 pr-0` } >
209+ { isLoading ? (
210+ < p className = "text-center text-secondary" > { t ( "common.loading" ) } </ p >
211+ ) : filteredOptions . length > 0 ? (
212+ filteredOptions . map ( ( option ) => (
213+ < Combobox . Option
214+ key = { option . value }
215+ value = { option . value }
216+ className = { ( { selected } ) =>
217+ `flex cursor-pointer select-none items-center justify-between gap-2 truncate rounded-sm px-1 py-1.5 hover:bg-layer-1 ${
218+ selected ? "text-primary" : "text-secondary"
219+ } `
220+ }
221+ >
222+ { ( { selected } ) => (
223+ < >
224+ { option . content }
225+ { selected && (
226+ < div className = "flex-shrink-0" >
227+ < Check className = { `h-3.5 w-3.5` } />
228+ </ div >
229+ ) }
230+ </ >
231+ ) }
232+ </ Combobox . Option >
233+ ) )
234+ ) : submitting ? (
235+ < Loader className = "spin h-3.5 w-3.5" />
236+ ) : canCreateLabel ? (
237+ < Combobox . Option
238+ value = { query }
239+ onClick = { ( e ) => {
240+ e . preventDefault ( ) ;
241+ e . stopPropagation ( ) ;
242+ if ( ! query . length ) return ;
243+ handleAddLabel ( query ) ;
244+ } }
245+ className = { `text-left text-secondary ${ query . length ? "cursor-pointer" : "cursor-default" } ` }
246+ >
247+ { query . length ? (
248+ < >
249+ { /* TODO: Translate here */ } + Add < span className = "text-primary" > "{ query } "</ span > to labels
250+ </ >
212251 ) : (
213- < p className = "text-left text-secondary " > { t ( "common.search.no_matching_results" ) } </ p >
252+ t ( "label.create.type" )
214253 ) }
215- </ div >
216- </ div >
217- </ Combobox . Options >
218- </ Combobox >
219- </ >
254+ </ Combobox . Option >
255+ ) : (
256+ < p className = "text-left text-secondary " > { t ( "common.search.no_matching_results" ) } </ p >
257+ ) }
258+ </ div >
259+ </ Combobox . Options >
260+ </ Combobox >
220261 ) ;
221262} ) ;
0 commit comments