Skip to content
Closed
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- `RadioControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)).
- `SelectControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)).
- `ComboboxControl`: Replace `keyboardEvent.keyCode` with `keyboardEvent.code`([#42569](https://github.com/WordPress/gutenberg/pull/42569)).
- `SearchControl`: Convert to TypeScript ([#42647](https://github.com/WordPress/gutenberg/pull/42647)).

## 19.15.0 (2022-07-13)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
import type { ForwardedRef } from 'react';
import classnames from 'classnames';

/**
Expand All @@ -14,8 +15,9 @@ import { forwardRef, useRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { Button } from '../';
import { Button } from '../button';

@kienstra kienstra Jul 22, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change, there's an error, probably from Button not being in TypeScript:

File 'plugins/gutenberg/packages/components/src/index.js' is not listed within the file list of project 'plugins/gutenberg/packages/components/tsconfig.json'. Projects must list all files or use an 'include' pattern.
The file is in the program because:
Imported via '../' from file 'plugins/gutenberg/packages/components/src/search-control/index.tsx'

import BaseControl from '../base-control';
import type { SearchControlProps } from './types';

function SearchControl(
{
Expand All @@ -28,10 +30,10 @@ function SearchControl(
hideLabelFromVision = true,
help,
onClose,
},
forwardedRef
}: SearchControlProps,
forwardedRef: ForwardedRef< any >
) {
const searchRef = useRef();
const searchRef = useRef< HTMLInputElement >();
const instanceId = useInstanceId( SearchControl );
const id = `components-search-control-${ instanceId }`;

Expand All @@ -53,7 +55,7 @@ function SearchControl(
label={ __( 'Reset search' ) }
onClick={ () => {
onChange( '' );
searchRef.current.focus();
searchRef.current?.focus();
} }
/>
);
Expand Down
21 changes: 21 additions & 0 deletions packages/components/src/search-control/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* External dependencies
*/
import type { KeyboardEventHandler } from 'react';

/**
* WordPress dependencies
*/
import type { WPElement } from '@wordpress/element';

export type SearchControlProps = {
className?: string;
onChange: ( arg0: string ) => {};
onKeyDown: KeyboardEventHandler< HTMLInputElement >;
value: string | number;
label: string;
placeholder?: string;
hideLabelFromVision?: boolean;
help?: string | WPElement;
onClose: VoidFunction;
};
1 change: 1 addition & 0 deletions packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"src/resizable-box/**/*",
"src/scroll-lock/**/*",
"src/scrollable/**/*",
"src/search-control/**/*",
"src/select-control/**/*",
"src/shortcut/**/*",
"src/slot-fill/**/*",
Expand Down