From 45b5ea94d4084156c8dd3c70288c57f638bb06af Mon Sep 17 00:00:00 2001 From: Armin Mehinovic Date: Fri, 22 Nov 2024 09:18:43 +0100 Subject: [PATCH] Skip rendering the whole startAdornment if speech recognition is not supported --- .../GridToolbarPromptControl.tsx | 6 ++- .../components/promptControl/RecordButton.tsx | 44 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx b/packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx index f3d37b32d71fb..7f08363cb4141 100644 --- a/packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx +++ b/packages/x-data-grid-premium/src/components/promptControl/GridToolbarPromptControl.tsx @@ -21,6 +21,8 @@ import { RecordButton, BrowserSpeechRecognition } from './RecordButton'; type OwnerState = DataGridPremiumProcessedProps; +const supportsSpeechRecognition = !!BrowserSpeechRecognition; + const useUtilityClasses = (ownerState: OwnerState, recording: boolean) => { const { classes } = ownerState; @@ -206,7 +208,7 @@ function GridToolbarPromptControl(props: GridToolbarPromptControlProps) { } }); - const placeholder = BrowserSpeechRecognition + const placeholder = supportsSpeechRecognition ? apiRef.current.getLocaleText('toolbarPromptControlWithRecordingPlaceholder') : apiRef.current.getLocaleText('toolbarPromptControlPlaceholder'); @@ -229,7 +231,7 @@ function GridToolbarPromptControl(props: GridToolbarPromptControlProps) { error={!!error} helperText={error} InputProps={{ - startAdornment: ( + startAdornment: supportsSpeechRecognition && ( -
- - - -
- - ) + +
+ + + +
+
); }