Skip to content

Commit a5fd9b1

Browse files
feat: improve customizer search visibility (#4456)
* feat: improve customizer search visibility
1 parent 9075cee commit a5fd9b1

File tree

4 files changed

+5
-94
lines changed

4 files changed

+5
-94
lines changed

assets/apps/customizer-controls/src/customizer-search/MainSearch.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createPortal } from '@wordpress/element';
22
import React, { useState } from 'react';
3-
import SearchToggle from './SearchToggle';
43
import SearchComponent, { Control } from './SearchComponent';
54
import SearchResults from './SearchResults';
65

@@ -20,23 +19,13 @@ type MainSearchProps = {
2019
* @class
2120
*/
2221
const MainSearch: React.FC<MainSearchProps> = ({ search, button, results }) => {
23-
const [isOpened, setIsOpened] = useState(false);
2422
const [query, setQuery] = useState('');
2523
const [matchResults, setMatchResults] = useState([] as Control[]);
2624

2725
return (
2826
<>
29-
{createPortal(
30-
<SearchToggle
31-
onToggle={() => {
32-
setIsOpened(!isOpened);
33-
}}
34-
/>,
35-
button
36-
)}
3727
{createPortal(
3828
<SearchComponent
39-
isOpened={isOpened}
4029
search={query}
4130
setSearch={setQuery}
4231
matchResults={matchResults}

assets/apps/customizer-controls/src/customizer-search/SearchComponent.tsx

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ declare global {
6060
* Type SearchComponentProps
6161
*/
6262
type SearchComponentProps = {
63-
isOpened: boolean;
6463
search: string;
6564
setSearch: (value: string) => void;
6665
matchResults: Control[];
@@ -75,7 +74,6 @@ type SearchComponentProps = {
7574
* @class
7675
*/
7776
const SearchComponent: React.FC<SearchComponentProps> = ({
78-
isOpened,
7977
search,
8078
setSearch,
8179
matchResults,
@@ -128,24 +126,6 @@ const SearchComponent: React.FC<SearchComponentProps> = ({
128126
});
129127
}, []);
130128

131-
/**
132-
* This `useEffect()` is being used to listen for the toggleEvent
133-
* from `SearchToggle` component.
134-
*/
135-
useEffect(() => {
136-
if (isOpened) {
137-
document
138-
.getElementById('neve-customize-search-field')
139-
?.classList.add('visible');
140-
document.getElementById('nv-customizer-search-input')?.focus();
141-
} else {
142-
document
143-
.getElementById('neve-customize-search-field')
144-
?.classList.remove('visible');
145-
clearField();
146-
}
147-
}, [isOpened]);
148-
149129
useEffect(() => {
150130
if (search === '') {
151131
if (customizerPanels?.classList.contains('search-not-found')) {
@@ -217,15 +197,12 @@ const SearchComponent: React.FC<SearchComponentProps> = ({
217197
return (
218198
<>
219199
<span className="accordion-section">
220-
<span className="search-input">
221-
{__('Search', 'neve') +
222-
' ' +
223-
__('Settings', 'neve').toLowerCase()}
224-
</span>
225200
<span className="nv-search-wrap">
226201
<input
227202
type="text"
228-
placeholder={__('Search', 'neve')}
203+
placeholder={
204+
__('Search', 'neve') + ' ' + __('Settings', 'neve')
205+
}
229206
id="nv-customizer-search-input"
230207
className="nv-customizer-search-input"
231208
value={search}

assets/apps/customizer-controls/src/customizer-search/SearchToggle.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

assets/apps/customizer-controls/src/scss/_customizer-search.scss

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
11
#neve-customize-search {
2-
position: absolute;
3-
top: 40px;
4-
right: 0;
5-
width: 40px;
6-
height: 28px;
7-
overflow: hidden;
8-
z-index: 1000;
9-
10-
button {
11-
text-decoration: none;
12-
&:focus:not(:disabled) {
13-
box-shadow: none;
14-
outline: none;
15-
}
16-
}
2+
display: none;
173
}
184

195

206
#neve-customize-search-field {
21-
display: none;
22-
&.visible {
23-
display: block;
24-
}
7+
display: block;
258

269
.accordion-section {
2710
background-color: #fff;
@@ -37,7 +20,6 @@
3720
.nv-search-wrap {
3821
display: flex;
3922
align-items: center;
40-
margin-top: 6px;
4123
}
4224

4325
.nv-customizer-search-input {

0 commit comments

Comments
 (0)