Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit a0bc731

Browse files
authored
fix: relation widget style fixes (#911)
1 parent 2d2b048 commit a0bc731

File tree

7 files changed

+65
-47
lines changed

7 files changed

+65
-47
lines changed

packages/core/src/components/common/autocomplete/Autocomplete.css

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.CMS_Autocomplete_root {
22
@apply relative
3-
w-full;
3+
w-full
4+
flex
5+
items-center
6+
gap-2
7+
pr-2;
48

59
&.CMS_Autocomplete_disabled {
610
& .CMS_Autocomplete_input {
@@ -15,13 +19,19 @@
1519
}
1620
}
1721

22+
.CMS_Autocomplete_input-wrapper {
23+
@apply flex-grow
24+
flex
25+
flex-wrap
26+
min-w-0;
27+
}
28+
1829
.CMS_Autocomplete_input {
1930
@apply w-full
2031
bg-transparent
2132
border-none
2233
py-2
2334
pl-3
24-
pr-10
2535
text-sm
2636
leading-5
2737
focus:ring-0
@@ -33,13 +43,10 @@
3343
}
3444

3545
.CMS_Autocomplete_button-wrapper {
36-
@apply absolute
37-
inset-y-0
38-
right-0
39-
flex
46+
@apply flex
4047
items-center
41-
pr-2
42-
gap-1;
48+
gap-1
49+
flex-shrink-0;
4350
}
4451

4552
.CMS_Autocomplete_button {

packages/core/src/components/common/autocomplete/Autocomplete.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const classes = generateClassNames('Autocomplete', [
2020
'root',
2121
'focused',
2222
'disabled',
23+
'input-wrapper',
2324
'input',
2425
'button-wrapper',
2526
'button',
@@ -55,6 +56,7 @@ export interface AutocompleteProps {
5556
disabled?: boolean;
5657
required?: boolean;
5758
inputRef?: Ref<HTMLInputElement>;
59+
endAdornment?: ReactNode;
5860
displayValue: (item: string | string[] | null) => string;
5961
onQuery: (query: string) => void;
6062
onChange: (value: string | string[] | undefined) => void;
@@ -64,9 +66,10 @@ const Autocomplete = ({
6466
label,
6567
value,
6668
options,
67-
inputRef,
6869
disabled,
6970
required,
71+
inputRef,
72+
endAdornment,
7073
onChange,
7174
onQuery,
7275
}: AutocompleteProps) => {
@@ -187,14 +190,17 @@ const Autocomplete = ({
187190
)}
188191
data-testid="autocomplete"
189192
>
190-
{label}
191-
<input
192-
{...getInputProps()}
193-
ref={finalInputRef}
194-
className={classes.input}
195-
data-testid="autocomplete-input"
196-
/>
193+
<div className={classes['input-wrapper']}>
194+
{label}
195+
<input
196+
{...getInputProps()}
197+
ref={finalInputRef}
198+
className={classes.input}
199+
data-testid="autocomplete-input"
200+
/>
201+
</div>
197202
<div className={classes['button-wrapper']}>
203+
{endAdornment}
198204
<IconButton
199205
variant="text"
200206
size="small"

packages/core/src/components/common/progress/CircularProgress.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.CMS_CircularProgress_svg {
2-
@apply mr-2
3-
text-gray-200
2+
@apply text-gray-200
43
animate-spin
54
dark:text-gray-600
65
fill-blue-600;

packages/core/src/styles/main.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,12 @@ table {
427427
height: 24px;
428428
}
429429
}
430+
431+
::-moz-focus-inner,
432+
:focus-visible {
433+
@apply outline-none;
434+
}
435+
436+
.MuiPopper-root {
437+
@apply z-[100];
438+
}

packages/core/src/widgets/relation/RelationControl.css

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
gap-2
88
p-2
99
pr-0
10-
w-relation-widget-label;
10+
min-w-0;
1111
}
1212

1313
.CMS_WidgetRelation_loading {
14-
@apply absolute
15-
inset-y-0
16-
right-4
17-
flex
14+
@apply flex
1815
items-center
19-
pr-2;
16+
w-6
17+
h-6;
2018
}

packages/core/src/widgets/relation/RelationControl.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -358,28 +358,18 @@ const RelationControl: FC<WidgetControlProps<string | string[], RelationField>>
358358
>
359359
<Autocomplete
360360
label={
361-
<>
362-
{Array.isArray(selectedValue) && selectedValue.length > 0 ? (
363-
<div className={classes.values}>
364-
{selectedValue.map(selectValue => {
365-
const option = uniqueOptionsByValue[selectValue];
366-
return (
367-
<Pill key={selectValue} noWrap disabled={disabled}>
368-
{option?.label ?? selectValue}
369-
</Pill>
370-
);
371-
})}
372-
</div>
373-
) : null}
374-
{loading ? (
375-
<CircularProgress
376-
key="loading-indicator"
377-
className={classes.loading}
378-
data-testid="relation-loading-indicator"
379-
size="small"
380-
/>
381-
) : null}
382-
</>
361+
Array.isArray(selectedValue) && selectedValue.length > 0 ? (
362+
<div className={classes.values}>
363+
{selectedValue.map(selectValue => {
364+
const option = uniqueOptionsByValue[selectValue];
365+
return (
366+
<Pill key={selectValue} noWrap disabled={disabled}>
367+
{option?.label ?? selectValue}
368+
</Pill>
369+
);
370+
})}
371+
</div>
372+
) : null
383373
}
384374
inputRef={ref}
385375
value={selectedValue}
@@ -398,6 +388,16 @@ const RelationControl: FC<WidgetControlProps<string | string[], RelationField>>
398388

399389
return option.label;
400390
}}
391+
endAdornment={
392+
loading ? (
393+
<CircularProgress
394+
key="loading-indicator"
395+
className={classes.loading}
396+
data-testid="relation-loading-indicator"
397+
size="small"
398+
/>
399+
) : null
400+
}
401401
onQuery={filterOptions}
402402
onChange={handleChange}
403403
/>

tailwind.base.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module.exports = {
3232
"breadcrumb-title": "calc(100vw * .4)",
3333
"collection-header": "calc(100% - 32px)",
3434
"date-widget": "calc(100% - 58px)",
35-
"relation-widget-label": "calc(100% - 32px)",
3635
"select-widget-label": "calc(100% - 12px)",
3736
},
3837
maxWidth: {

0 commit comments

Comments
 (0)