@@ -17,12 +17,12 @@ import { getEditorSettings, patchEditorSettings } from "@/lib/ai-edition/store/e
1717import { useProjectStore } from "@/lib/ai-edition/store/projectStore" ;
1818import { useEditorSettings } from "@/lib/ai-edition/store/useEditorSettings" ;
1919import {
20+ FACTORY_STYLE_PRESET_ID ,
2021 type StylePreset ,
2122 type StylePresetAppearance ,
2223 sanitizeStylePresetName ,
2324} from "@/lib/ai-edition/stylePresets" ;
2425import {
25- FACTORY_STYLE_PRESET_ID ,
2626 factoryStylePresetAppearance ,
2727 stylePresetAppearanceFromSettings ,
2828 stylePresetPatch ,
@@ -96,7 +96,7 @@ function NameForm({
9696} : NameFormProps ) {
9797 const [ name , setName ] = useState ( initialName ) ;
9898 const onKeyDown = ( event : KeyboardEvent < HTMLInputElement > ) => {
99- if ( event . key === "Enter" ) {
99+ if ( event . key === "Enter" && ! busy ) {
100100 event . preventDefault ( ) ;
101101 onSubmit ( name ) ;
102102 }
@@ -106,6 +106,7 @@ function NameForm({
106106 < div className = { styles . presetForm } >
107107 < input
108108 type = "text"
109+ disabled = { busy }
109110 autoFocus
110111 value = { name }
111112 placeholder = { placeholder }
@@ -188,16 +189,16 @@ export function StylePresetsMenu() {
188189 const current = stylePresetAppearanceFromSettings ( settings ) ;
189190 const factory = factoryStylePresetAppearance ( ) ;
190191
191- const apply = ( appearance : StylePresetAppearance , name : string ) => {
192+ const apply = async ( appearance : StylePresetAppearance , name : string ) => {
192193 setOpen ( false ) ;
193194 const patch = stylePresetPatch ( appearance ) ;
195+ if ( ! ( await set ( patch ) ) ) return ;
194196 // The overlay only pushes native params on mount, and each control here pushes its own
195197 // diff; a preset touches all of them at once, so it pushes the whole resulting snapshot.
196198 const doc = useProjectStore . getState ( ) . document ;
197199 if ( doc && isNativeCompositorActive ( ) ) {
198200 pushAllNativeParams ( getEditorSettings ( patchEditorSettings ( doc , patch ) ) ) ;
199201 }
200- void set ( patch ) ;
201202 toast . success ( ts ( "stylePresets.applied" , { name } ) ) ;
202203 } ;
203204
@@ -323,7 +324,7 @@ export function StylePresetsMenu() {
323324 role = "menuitemradio"
324325 aria-checked = { active }
325326 className = { rowClass ( active ) }
326- onClick = { ( ) => apply ( preset . appearance , preset . name ) }
327+ onClick = { ( ) => void apply ( preset . appearance , preset . name ) }
327328 >
328329 < span className = { styles . presetCheck } aria-hidden = "true" >
329330 { active ? < Check size = { 12 } /> : null }
@@ -433,7 +434,7 @@ export function StylePresetsMenu() {
433434 aria-checked = { factoryActive }
434435 key = { FACTORY_STYLE_PRESET_ID }
435436 className = { rowClass ( factoryActive ) }
436- onClick = { ( ) => apply ( factory , ts ( "stylePresets.factoryName" ) ) }
437+ onClick = { ( ) => void apply ( factory , ts ( "stylePresets.factoryName" ) ) }
437438 >
438439 < span className = { styles . presetCheck } aria-hidden = "true" >
439440 { factoryActive ? < Check size = { 12 } /> : null }
0 commit comments