Skip to content

Commit 65849ab

Browse files
authored
fix(TextInput): input styling (#733)
1 parent 6d62f82 commit 65849ab

23 files changed

+293
-216
lines changed

.changeset/curly-trainers-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Fix minor issues with input styling.

.changeset/famous-items-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Expose shouldFocusWrap for ListBox, FilterListBox, and FilterPicker to control whether keyboard navigation should wrap around.

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
437437
}}
438438
data-size={size}
439439
>
440+
{prefix ? <div data-element="Prefix">{prefix}</div> : null}
440441
<InputElement
441442
ref={inputRef}
442443
qa="Input"
@@ -448,7 +449,6 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
448449
{...modAttrs(mods)}
449450
data-size={size}
450451
/>
451-
{prefix ? <div data-element="Prefix">{prefix}</div> : null}
452452
<div data-element="Suffix">
453453
{suffixPosition === 'before' ? suffix : null}
454454
{validationState || isLoading ? (

src/components/fields/DatePicker/DateInputBase.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ const DateInputElement = tasty({
3232
role: 'presentation',
3333
styles: {
3434
...DEFAULT_INPUT_STYLES,
35+
height: {
36+
'': '(@size-md - 2bw)',
37+
'[data-size="small"]': '(@size-sm - 2bw)',
38+
'[data-size="large"]': '(@size-lg - 2bw)',
39+
},
3540
display: 'flex',
3641
flow: 'row',
3742
placeItems: 'center start',

src/components/fields/FilterListBox/FilterListBox.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ const meta: Meta<typeof FilterListBox> = {
135135
defaultValue: { summary: false },
136136
},
137137
},
138+
shouldFocusWrap: {
139+
control: { type: 'boolean' },
140+
description: 'Whether keyboard navigation should wrap around',
141+
table: {
142+
defaultValue: { summary: false },
143+
},
144+
},
138145

139146
/* State */
140147
isLoading: {

src/components/fields/FilterListBox/FilterListBox.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ const SearchInputElement = tasty({
8484
...DEFAULT_INPUT_STYLES,
8585
fill: '#clear',
8686
padding: {
87-
'': '.5x 1.5x',
88-
prefix: '.5x 1.5x .5x .5x',
87+
'': '0 1.5x',
88+
prefix: '0 1.5x 0 .5x',
8989
},
9090
},
9191
});
@@ -194,6 +194,7 @@ export const FilterListBox = forwardRef(function FilterListBox<
194194
description,
195195
styles,
196196
focusOnHover,
197+
shouldFocusWrap,
197198
labelSuffix,
198199
selectedKey,
199200
defaultSelectedKey,
@@ -607,7 +608,7 @@ export const FilterListBox = forwardRef(function FilterListBox<
607608
const newIndex = currentIndex + direction;
608609
if (newIndex >= 0 && newIndex < visibleKeys.length) {
609610
nextKey = visibleKeys[newIndex];
610-
} else {
611+
} else if (shouldFocusWrap) {
611612
// Wrap around
612613
nextKey = isArrowDown
613614
? visibleKeys[0]
@@ -715,6 +716,7 @@ export const FilterListBox = forwardRef(function FilterListBox<
715716
focused: isFocused,
716717
loading: !!isLoading,
717718
searchable: true,
719+
prefix: !!isLoading,
718720
...externalMods,
719721
}),
720722
[
@@ -784,7 +786,14 @@ export const FilterListBox = forwardRef(function FilterListBox<
784786
};
785787

786788
const searchInput = (
787-
<SearchWrapperElement mods={mods} data-size="small">
789+
<SearchWrapperElement mods={mods} data-size={size}>
790+
{isLoading && (
791+
<div data-element="Prefix">
792+
<div data-element="InputIcon">
793+
{isLoading ? <LoadingIcon /> : null}
794+
</div>
795+
</div>
796+
)}
788797
<SearchInputElement
789798
ref={searchInputRef}
790799
data-is-prefix={isLoading ? '' : undefined}
@@ -811,13 +820,6 @@ export const FilterListBox = forwardRef(function FilterListBox<
811820
{...keyboardProps}
812821
{...modAttrs(mods)}
813822
/>
814-
{isLoading && (
815-
<div data-element="Prefix">
816-
<div data-element="InputIcon">
817-
{isLoading ? <LoadingIcon /> : null}
818-
</div>
819-
</div>
820-
)}
821823
</SearchWrapperElement>
822824
);
823825

@@ -856,6 +858,7 @@ export const FilterListBox = forwardRef(function FilterListBox<
856858
listRef={listRef}
857859
stateRef={listStateRef}
858860
listStyles={listStyles}
861+
shouldFocusWrap={shouldFocusWrap}
859862
optionStyles={optionStyles}
860863
sectionStyles={sectionStyles}
861864
headingStyles={headingStyles}

src/components/fields/FilterPicker/FilterPicker.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ const meta: Meta<typeof FilterPicker> = {
161161
defaultValue: { summary: false },
162162
},
163163
},
164+
shouldFocusWrap: {
165+
control: { type: 'boolean' },
166+
description: 'Whether keyboard navigation should wrap around',
167+
table: {
168+
defaultValue: { summary: false },
169+
},
170+
},
164171

165172
/* State */
166173
isDisabled: {

0 commit comments

Comments
 (0)