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

[EuiRadio] Make id required if label is present #3382

Merged
merged 6 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

**Bug Fixes**

- Added need of `id` if `lable` is passed to issue in `EuiRadio` ([#3382](https://github.com/elastic/eui/pull/3382))
thompsongl marked this conversation as resolved.
Show resolved Hide resolved
- Fixed z-index issue in `EuiDatePicker` where it's popover would sit beneath other DOM siblings that had z-index applied ([#3376](https://github.com/elastic/eui/pull/3376))
- Added `download` glyph to `EuiIcon` ([#3364](https://github.com/elastic/eui/pull/3364))
- Applies `max-width: 100%` to `EuiPageBody` so inner flex-based items don't overflow their containers ([#3375](https://github.com/elastic/eui/pull/3375))
Expand Down
19 changes: 13 additions & 6 deletions src/components/form/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,33 @@ import React, {
ReactNode,
} from 'react';
import classNames from 'classnames';
import { CommonProps } from '../../common';
import { CommonProps, ExclusiveUnion } from '../../common';

export interface RadioProps {
autoFocus?: boolean;
/**
* When `true` creates a shorter height radio row
*/
compressed?: boolean;
label?: ReactNode;
name?: string;
value?: string;
checked?: boolean;
disabled?: boolean;
onChange: ChangeEventHandler<HTMLInputElement>;
}

export interface EuiRadioProps
extends CommonProps,
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>,
RadioProps {}
interface idWithLable extends RadioProps {
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
label: ReactNode;
id: string;
}

interface withId extends RadioProps {
id: string;
}

export type EuiRadioProps = CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> &
ExclusiveUnion<ExclusiveUnion<RadioProps, idWithLable>, withId>;
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved

export const EuiRadio: FunctionComponent<EuiRadioProps> = ({
className,
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/radio/radio_group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const EuiRadioGroup: FunctionComponent<EuiRadioGroupProps> = ({
disabled={disabled || isOptionDisabled}
onChange={onChange.bind(null, option.id, option.value)}
compressed={compressed}
{...optionRest}
{...optionRest as EuiRadioProps}
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
/>
);
});
Expand Down