From 515263284faf350b4f7d2d920714f0538dcef4b0 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Mon, 14 Jan 2019 18:11:29 -0500 Subject: [PATCH 1/3] Add inputRef prop to EuiFieldNumber and allow callbacks in select inputRef --- src/components/form/field_number/field_number.js | 2 ++ src/components/form/field_number/index.d.ts | 1 + src/components/form/select/index.d.ts | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/form/field_number/field_number.js b/src/components/form/field_number/field_number.js index 352ec8bd026..6af1712657b 100644 --- a/src/components/form/field_number/field_number.js +++ b/src/components/form/field_number/field_number.js @@ -25,6 +25,7 @@ export const EuiFieldNumber = ({ compressed, prepend, append, + inputRef, ...rest }) => { const classes = classNames('euiFieldNumber', className, { @@ -54,6 +55,7 @@ export const EuiFieldNumber = ({ value={value} placeholder={placeholder} className={classes} + ref={inputRef} {...rest} /> diff --git a/src/components/form/field_number/index.d.ts b/src/components/form/field_number/index.d.ts index 0f6f313cb2d..33dd239f103 100644 --- a/src/components/form/field_number/index.d.ts +++ b/src/components/form/field_number/index.d.ts @@ -18,6 +18,7 @@ declare module '@elastic/eui' { compressed?: boolean; prepend?: ReactNode | ReactNode[]; append?: ReactNode | ReactNode[]; + inputRef?: (element: HTMLInputElement) => void; } export const EuiFieldNumber: SFC< diff --git a/src/components/form/select/index.d.ts b/src/components/form/select/index.d.ts index 051d3e85fee..a1eef58908f 100644 --- a/src/components/form/select/index.d.ts +++ b/src/components/form/select/index.d.ts @@ -16,7 +16,7 @@ declare module '@elastic/eui' { fullWidth?: boolean; isLoading?: boolean; hasNoInitialSelection?: boolean; - inputRef?: Ref; + inputRef?: Ref | ((ref: HTMLInputElement) => void); compressed?: boolean; prepend?: ReactNode | ReactNode[]; append?: ReactNode | ReactNode[]; From 500a585ddd1e80bdc9ea434582f9e3cd3bedd904 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Thu, 17 Jan 2019 17:32:25 -0500 Subject: [PATCH 2/3] ref updates --- src/components/form/field_number/index.d.ts | 6 +++--- src/components/form/field_text/index.d.ts | 4 ++-- src/components/form/select/index.d.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/form/field_number/index.d.ts b/src/components/form/field_number/index.d.ts index 33dd239f103..64a25bce56d 100644 --- a/src/components/form/field_number/index.d.ts +++ b/src/components/form/field_number/index.d.ts @@ -1,7 +1,7 @@ import { CommonProps } from '../../common'; -import { IconType } from '../../icon' +import { IconType } from '../../icon'; -import { ReactNode, SFC, InputHTMLAttributes } from 'react'; +import { ReactNode, SFC, InputHTMLAttributes, Ref } from 'react'; declare module '@elastic/eui' { @@ -18,7 +18,7 @@ declare module '@elastic/eui' { compressed?: boolean; prepend?: ReactNode | ReactNode[]; append?: ReactNode | ReactNode[]; - inputRef?: (element: HTMLInputElement) => void; + inputRef?: Ref; } export const EuiFieldNumber: SFC< diff --git a/src/components/form/field_text/index.d.ts b/src/components/form/field_text/index.d.ts index 0e969d040ec..8da08c61490 100644 --- a/src/components/form/field_text/index.d.ts +++ b/src/components/form/field_text/index.d.ts @@ -1,6 +1,6 @@ import { CommonProps } from '../../common'; -import { SFC, InputHTMLAttributes } from 'react'; +import { SFC, InputHTMLAttributes, Ref } from 'react'; declare module '@elastic/eui' { @@ -12,7 +12,7 @@ declare module '@elastic/eui' { export interface EuiFieldTextProps { icon?: string; isInvalid?: boolean; - inputRef?: (ref: HTMLInputElement) => void; + inputRef?: Ref; fullWidth?: boolean; isLoading?: boolean; prepend?: React.ReactNode; diff --git a/src/components/form/select/index.d.ts b/src/components/form/select/index.d.ts index a1eef58908f..051d3e85fee 100644 --- a/src/components/form/select/index.d.ts +++ b/src/components/form/select/index.d.ts @@ -16,7 +16,7 @@ declare module '@elastic/eui' { fullWidth?: boolean; isLoading?: boolean; hasNoInitialSelection?: boolean; - inputRef?: Ref | ((ref: HTMLInputElement) => void); + inputRef?: Ref; compressed?: boolean; prepend?: ReactNode | ReactNode[]; append?: ReactNode | ReactNode[]; From 08da2d8e330eb03345cc233d6cd6a652ed500959 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Thu, 17 Jan 2019 17:35:57 -0500 Subject: [PATCH 3/3] Add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f08ca01b9f5..3048fb17d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `6.5.0`. +- Added `inputRef` prop to `EuiFieldNumber` and updated `EuiFieldText`'s to a Ref type ([#1434](https://github.com/elastic/eui/pull/1434)) ## [`6.5.0`](https://github.com/elastic/eui/tree/v6.5.0)