fix(search): replace createRef with useRef for microphone icon

This commit is contained in:
alexsparkes
2026-01-24 14:39:35 +00:00
parent 17bbdeb7b9
commit 64f69bbbbd
2 changed files with 49 additions and 38 deletions

View File

@@ -1,9 +1,11 @@
/* global chrome */
import variables from 'config/variables';
import { memo, createRef, useEffect, useState, useCallback } from 'react';
import { memo, useRef, useEffect, useState, useCallback } from 'react';
import { MdSearch, MdMic } from 'react-icons/md';
import { Tooltip } from 'components/Elements';
import EventBus from 'utils/eventbus';
import './search.scss';
function Search() {
@@ -12,7 +14,7 @@ function Search() {
localStorage.getItem('widgetStyle') === 'legacy' ? 'searchIcons old' : 'searchIcons',
);
const micIcon = createRef();
const micIcon = useRef(null);
const startSpeechRecognition = useCallback(() => {
const voiceSearch = new window.webkitSpeechRecognition();
@@ -64,8 +66,10 @@ function Search() {
<MdMic className="micIcon" />
</button>,
);
} else {
setMicrophone(null);
}
}, [micIcon, startSpeechRecognition]);
}, [startSpeechRecognition]);
useEffect(() => {
init();
@@ -75,6 +79,12 @@ function Search() {
element.focus();
}
}
EventBus.on('refresh', (data) => {
if (data === 'search') {
init();
}
});
}, [init]);
function searchButton(e) {

View File

@@ -6,7 +6,6 @@ import { Checkbox } from 'components/Form/Settings';
import EventBus from 'utils/eventbus';
const SearchOptions = () => {
const SEARCH_SECTION = 'modals.main.settings.sections.search';
const ChromePolicyWarning = () => {
@@ -48,6 +47,8 @@ const SearchOptions = () => {
);
};
const SearchOptions = () => {
return (
<>
<Header