/**
 * EntitySearchInput component.
 *
 * Site Kit by Google, Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * WordPress dependencies
 */
import { useCallback, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies
 */
import Button from './Button';
import MagnifyingGlass from '../../svg/magnifying-glass.svg';

function EntitySearchInput() {
	const [ isActive, setIsActive ] = useState( false );

	const onActive = useCallback( () => {
		setIsActive( true );
	}, [] );

	const onBlur = useCallback( () => {
		setIsActive( false );
	}, [] );

	if ( isActive ) {
		// eslint-disable-next-line jsx-a11y/no-autofocus
		return <input autoFocus onBlur={ onBlur } />;
	}

	return (
		<div className="googlesitekit-dropdown-menu googlesitekit-dropdown-menu__icon-menu">
			<Button
				text
				onClick={ onActive }
				trailingIcon={ <MagnifyingGlass width="30" height="20" /> }
				className="mdc-button--dropdown"
			>
				{ __( 'URL Search', 'google-site-kit' ) }
			</Button>
		</div>
	);
}

export default EntitySearchInput;

@@ -687,16 +687,26 @@
 import %7B
+ Fragment,
  useCall
@@ -749,16 +749,16 @@
 ement';%0A
-
 import %7B
@@ -852,16 +852,63 @@
 utton';%0A
+import VisuallyHidden from './VisuallyHidden';%0A
 import M
@@ -1214,18 +1214,200 @@
 e ) %7B%0A%09%09
-//
+return (%0A%09%09%09%3CFragment%3E%0A%09%09%09%09%3CVisuallyHidden%3E%0A%09%09%09%09%09%3Clabel htmlFor=%22entity-search-input%22%3E%0A%09%09%09%09%09%09%7B __( 'Page/URL Search', 'google-site-kit' ) %7D%0A%09%09%09%09%09%3C/label%3E%0A%09%09%09%09%3C/VisuallyHidden%3E%0A%09%09%09%09%7B /*
  eslint-
@@ -1449,24 +1449,49 @@
 ocus
-%0A%09%09return %3C
+ */ %7D%0A%09%09%09%09%3Cinput id=%22entity-search-
 input
+%22
  aut
@@ -1517,16 +1517,35 @@
 lur %7D /%3E
+%0A%09%09%09%3C/Fragment%3E%0A%09%09)
 ;%0A%09%7D%0A%0A%09r

Add label to search field.