From 2fa88471453a77c0f56f530a82b9609ad3e48df7 Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Mon, 7 Jan 2019 14:07:00 -0500 Subject: [PATCH] Adds initialFocus prop typedefs (#1410) ### Summary Adds type definitions for the `initialFocus` prop available on `EuiModal` and `EuiPopover` (discovered via https://github.com/elastic/kibana/pull/28195) ### Checklist - [ ] This was checked in mobile - [ ] This was checked in IE11 - [ ] This was checked in dark mode - [ ] Any props added have proper autodocs - [ ] Documentation examples were added - [ ] A [changelog](https://github.com/elastic/eui/blob/master/CHANGELOG.md) entry exists and is marked appropriately - [ ] This was checked for breaking changes and labeled appropriately - [ ] Jest tests were updated or added to match the most common scenarios - [ ] This was checked against keyboard-only and screenreader scenarios - [ ] This required updates to Framer X components --- CHANGELOG.md | 1 + src/components/modal/index.d.ts | 7 +++++++ src/components/popover/index.d.ts | 2 ++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74feacf05d0..8c236195f7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [`master`](https://github.com/elastic/eui/tree/master) - Added `onBlur` prop to `EuiComboBox` ([#1400](https://github.com/elastic/eui/pull/1400)) +- Added `initialFocus` prop typedefs to `EuiModal` and `EuiPopover` ([#1410](https://github.com/elastic/eui/pull/1410)) ## [`6.2.0`](https://github.com/elastic/eui/tree/v6.2.0) diff --git a/src/components/modal/index.d.ts b/src/components/modal/index.d.ts index 076c848cd5d..d73cb177d3e 100644 --- a/src/components/modal/index.d.ts +++ b/src/components/modal/index.d.ts @@ -1,6 +1,7 @@ import { CommonProps, Omit } from '../common'; /// +import { FocusTarget } from 'focus-trap'; import { ReactNode, SFC, HTMLAttributes } from 'react'; declare module '@elastic/eui' { @@ -20,6 +21,12 @@ declare module '@elastic/eui' { * set to a string for a custom width in custom measurement. */ maxWidth?: boolean | number | string; + + /** + * Specifies what element should initially have focus; + * Can be a DOM node, or a selector string (which will be passed to document.querySelector() to find the DOM node), or a function that returns a DOM node. + */ + initialFocus?: FocusTarget; } export const EuiModal: SFC< diff --git a/src/components/popover/index.d.ts b/src/components/popover/index.d.ts index 65e5bd57008..1a691f20f2e 100644 --- a/src/components/popover/index.d.ts +++ b/src/components/popover/index.d.ts @@ -1,6 +1,7 @@ import { CommonProps, NoArgCallback } from '../common'; /// +import { FocusTarget } from 'focus-trap'; import { SFC, ReactNode, HTMLAttributes } from 'react'; declare module '@elastic/eui' { @@ -31,6 +32,7 @@ declare module '@elastic/eui' { withTitle?: boolean; isOpen?: boolean; ownFocus?: boolean; + initialFocus?: FocusTarget; hasArrow?: boolean; anchorClassName?: string; anchorPosition?: PopoverAnchorPosition;