Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Field): pass qa prop (#498) #503

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-emus-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Pass `qa` prop for fields.
3 changes: 2 additions & 1 deletion src/components/forms/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,14 @@ function Checkbox(
isHidden={isHidden}
mods={mods}
styles={{ position: 'relative' }}
qa="CheckboxWrapper"
>
<HiddenInput
data-qa="HiddenInput"
{...mergeProps(inputProps, focusProps)}
ref={inputRef}
/>
<CheckboxElement qa={qa || 'Checkbox'} mods={mods} styles={inputStyles}>
<CheckboxElement qa="Checkbox" mods={mods} styles={inputStyles}>
{markIcon}
</CheckboxElement>
{children && <Text nowrap>{children}</Text>}
Expand Down
2 changes: 2 additions & 0 deletions src/components/forms/FieldWrapper/FieldWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const FieldWrapper = forwardRef(function FieldWrapper(
) {
const {
as,
qa,
labelPosition = 'top',
label,
extra,
Expand Down Expand Up @@ -157,6 +158,7 @@ export const FieldWrapper = forwardRef(function FieldWrapper(
<>
<FieldElement
ref={ref}
qa={qa}
as={as ?? 'div'}
mods={mods}
isHidden={isHidden}
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/FieldWrapper/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Props, Styles } from '../../../tasty';
// ADDING NEW PROPS TO THIS INTERFACE REQUIRES ADDING THEM TO createFieldWrapperPropsKeys FUNCTION

export type CubeFieldWrapperProps = {
qa?: string;
as?: string;
validationState?: ValidationState;
styles?: Styles;
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/TextInput/TextInputBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function _TextInputBase(props: CubeTextInputBaseProps, ref) {
const textField = (
<InputWrapperElement
ref={wrapperRef}
qa={qa || 'TextInput'}
qa="TextInput"
mods={modifiers}
data-size={size}
styles={wrapperStyles}
Expand Down
4 changes: 3 additions & 1 deletion src/components/forms/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function wrapWithField<T extends WrapWithFieldProps>(
props: T,
) {
let {
qa,
label,
extra,
labelPosition = 'top',
Expand All @@ -40,8 +41,9 @@ export function wrapWithField<T extends WrapWithFieldProps>(
return (
<FieldWrapper
{...{
label,
qa,
extra,
label,
labelPosition,
labelStyles,
isRequired,
Expand Down
8 changes: 6 additions & 2 deletions src/components/pickers/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
BLOCK_STYLES,
extractStyles,
OUTER_STYLES,
Props,
tasty,
} from '../../../tasty';
import { useFocus } from '../../../utils/react/interactions';
Expand Down Expand Up @@ -116,6 +117,7 @@ export interface CubeComboBoxProps<T>
/** An optional keyboard delegate implementation, to override the default. */
keyboardDelegate?: KeyboardDelegate;
loadingState?: LoadingState;
wrapperProps?: Props;
/**
* The filter function used to determine if a option should be included in the combo box list.
* Has no effect when `items` is provided.
Expand Down Expand Up @@ -179,6 +181,7 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
filter,
styles,
labelSuffix,
wrapperProps,
...otherProps
} = props;

Expand Down Expand Up @@ -333,16 +336,17 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
let comboBoxField = (
<ComboBoxWrapperElement
ref={wrapperRef}
qa={qa || 'ComboBox'}
qa="ComboBoxWrapper"
{...modAttrs(mods)}
styles={outerStyles}
style={{
zIndex: isFocused ? 1 : 'initial',
}}
data-size={size}
wrapperProps={wrapperProps}
>
<InputElement
qa="Input"
qa="ComboBoxInput"
{...mergeProps(inputProps, hoverProps, focusProps)}
ref={inputRef}
autoComplete={autoComplete}
Expand Down
6 changes: 5 additions & 1 deletion src/components/pickers/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export interface CubeSelectBaseProps<T>
inputProps?: Props;
type?: 'secondary' | 'clear' | 'primary' | (string & {});
suffixPosition?: 'before' | 'after';
wrapperProps?: Props;
}

export interface CubeSelectProps<T> extends CubeSelectBaseProps<T> {
Expand Down Expand Up @@ -328,6 +329,7 @@ function Select<T extends object>(
labelSuffix,
ellipsis,
suffixPosition = 'before',
wrapperProps,
...otherProps
} = props;
let state = useSelectState(props);
Expand Down Expand Up @@ -414,12 +416,13 @@ function Select<T extends object>(

let selectField = (
<SelectWrapperElement
qa={qa || 'Select'}
qa="SelectWrapper"
mods={modifiers}
styles={outerStyles}
data-size={size}
data-type={type}
data-theme={theme}
wrapperProps={wrapperProps}
>
<HiddenSelect
state={state}
Expand All @@ -430,6 +433,7 @@ function Select<T extends object>(
<SelectElement
{...mergeProps(buttonProps, hoverProps, focusProps)}
ref={triggerRef}
qa="Select"
styles={inputStyles}
data-theme={theme}
data-size={size}
Expand Down
Loading