@@ -12,7 +12,7 @@ import {
1212 Typography ,
1313 type TypographyVariants ,
1414} from "@mui/material" ;
15- import { useRef } from "react" ;
15+ import { useRef , type SyntheticEvent } from "react" ;
1616import { toast } from "sonner" ;
1717import { DEFAULT_FONT , DEFAULT_THEME , EXAMPLE_GOOGLE_FONTS , WEB_SAFE_FONTS } from "../../constants" ;
1818import { useInnerTheme } from "../../hooks/useInnerTheme" ;
@@ -57,6 +57,12 @@ export const TextEditor = () => {
5757 }
5858 } ;
5959
60+ const handleAutoCompleteChange = ( _ : SyntheticEvent , value : string | null ) => {
61+ if ( ! value || value === DEFAULT_FONT ) {
62+ deleteThemeOptionKey ( [ "typography" , "fontFamily" ] ) ;
63+ } else mergeThemeOptions ( { typography : { fontFamily : value } } ) ;
64+ } ;
65+
6066 return (
6167 < >
6268 < FieldGroupContainer title = "Text Size" >
@@ -73,16 +79,8 @@ export const TextEditor = () => {
7379 </ FieldGroupContainer >
7480 < FieldGroupContainer title = "Font Family" >
7581 < Autocomplete
76- onChange = { ( _ , value ) => {
77- if ( ! value || value === DEFAULT_FONT ) {
78- deleteThemeOptionKey ( [ "typography" , "fontFamily" ] ) ;
79- } else mergeThemeOptions ( { typography : { fontFamily : value } } ) ;
80- } }
81- onInputChange = { ( _ , value ) => {
82- if ( ! value || value === DEFAULT_FONT ) {
83- deleteThemeOptionKey ( [ "typography" , "fontFamily" ] ) ;
84- } else mergeThemeOptions ( { typography : { fontFamily : value } } ) ;
85- } }
82+ onChange = { handleAutoCompleteChange }
83+ onInputChange = { handleAutoCompleteChange }
8684 value = { currentFont }
8785 inputValue = { currentFont }
8886 freeSolo
@@ -98,7 +96,7 @@ export const TextEditor = () => {
9896 }
9997 } }
10098 fullWidth
101- slotProps = { { listbox : { sx : { border : 1 , borderColor : "#444 " } } } }
99+ slotProps = { { listbox : { sx : { border : 1 , borderColor : "divider " } } } }
102100 renderInput = { ( params ) => < TextField { ...params } /> }
103101 renderGroup = { ( params ) => (
104102 < li key = { params . key } >
0 commit comments