Skip to content

Commit

Permalink
feat(DFD-632): AffixSelect data-testid (#5186)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgendre authored Feb 15, 2024
1 parent 10a8f45 commit 1a06e6f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-bulldogs-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/design-system': minor
---

data-testid on select suffix and input primitive
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { forwardRef } from 'react';
import type { MouseEvent, Ref } from 'react';

import classnames from 'classnames';

// eslint-disable-next-line @talend/import-depth
import { IconNameWithSize } from '@talend/icons/dist/typeUtils';

import { mergeRefs } from '../../../../mergeRef';
import { DeprecatedIconNames } from '../../../../types';
import { Tooltip, TooltipChildrenFnProps, TooltipChildrenFnRef } from '../../../Tooltip';
import { StackHorizontal } from '../../../Stack';
import { Clickable, ClickableProps } from '../../../Clickable';
import { getIconWithDeprecatedSupport } from '../../../Icon/DeprecatedIconHelper';
import { SizedIcon } from '../../../Icon';
import { getIconWithDeprecatedSupport } from '../../../Icon/DeprecatedIconHelper';
import { StackHorizontal } from '../../../Stack';
import { Tooltip, TooltipChildrenFnProps, TooltipChildrenFnRef } from '../../../Tooltip';

import styles from '../AffixStyles.module.scss';
import { mergeRefs } from '../../../../mergeRef';

type CommonAffixButtonPropsType = {
dataTestid?: string;
children: string;
isDropdown?: boolean;
onClick: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { forwardRef, Ref } from 'react';

import { DataAttributes } from 'src/types';

import { useId } from '../../../../useId';
import FieldPrimitive, { FieldPropsPrimitive } from '../../Primitives/Field/Field';
import SelectNoWrapper, { SelectNoWrapperProps } from '../../Primitives/Select/SelectNoWrapper';
import { useId } from '../../../../useId';

export type AffixSelectPropsType = Omit<FieldPropsPrimitive, 'hasError' | 'description'> &
Omit<SelectNoWrapperProps, 'isAffix' | 'className' | 'style'> & {
isSuffix: boolean;
};
} & Partial<DataAttributes>;

const AffixSelect = forwardRef((props: AffixSelectPropsType, ref: Ref<HTMLSelectElement>) => {
const { label, children, name, id, isSuffix, ...rest } = props;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import {
FocusEvent,
forwardRef,
InputHTMLAttributes,
Ref,
useImperativeHandle,
useRef,
FocusEvent,
} from 'react';

import classnames from 'classnames';
import InputWrapper, { AffixesProps } from '../InputWrapper/InputWrapper';
import { FieldStatusProps } from '../Field/Field';
import { DataAttributes } from 'src/types';

import useRevealPassword from '../../../Form/Field/Input/hooks/useRevealPassword';
import { SizedIcon } from '../../../Icon';
import { FieldStatusProps } from '../Field/Field';
import InputWrapper, { AffixesProps } from '../InputWrapper/InputWrapper';

import styles from './Input.module.scss';

export type InputPrimitiveProps = Omit<InputHTMLAttributes<any>, 'prefix' | 'suffix'> &
AffixesProps &
Omit<FieldStatusProps, 'errorMessage'>;
Omit<FieldStatusProps, 'errorMessage'> &
Partial<DataAttributes>;

const Input = forwardRef((props: InputPrimitiveProps, ref: Ref<HTMLInputElement | null>) => {
const {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { forwardRef, ReactElement, Ref } from 'react';
import { isElement } from 'react-is';

import classnames from 'classnames';

import AffixButton, { AffixButtonPropsType } from '../../../Form/Affix/variations/AffixButton';
import AffixReadOnly, {
AffixReadOnlyPropsType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type SelectNoWrapperProps = Omit<SelectHTMLAttributes<any>, 'prefix'> & {
hasError?: boolean;
isAffix?: boolean;
isSuffix?: boolean;
dataTestid?: string;
};

const SelectNoWrapper = forwardRef((props: SelectNoWrapperProps, ref: Ref<HTMLSelectElement>) => {
Expand All @@ -25,12 +26,14 @@ const SelectNoWrapper = forwardRef((props: SelectNoWrapperProps, ref: Ref<HTMLSe
isAffix = false,
isSuffix = false,
id,
dataTestid,
...rest
} = props;
return (
<div className={styles.select__wrapper}>
<select
{...rest}
data-testid={dataTestid}
disabled={disabled}
ref={ref}
id={id}
Expand Down

0 comments on commit 1a06e6f

Please sign in to comment.