File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -254,17 +254,21 @@ async function apply(): Promise<void> {
254254 return ;
255255 }
256256
257- const noPresetName : boolean =
258- [ "add" , "edit" ] . includes ( action ) &&
259- presetName . replace ( / ^ _ + | _ + $ / g, "" ) . length === 0 ; //all whitespace names are rejected
260- if ( noPresetName ) {
261- Notifications . add ( "Preset name cannot be empty" , 0 ) ;
262- return ;
263- }
257+ const addOrEditAction = action === "add" || action === "edit" ;
258+ if ( addOrEditAction ) {
259+ //validate the preset name only in add or edit mode
260+
261+ const noPresetName : boolean =
262+ presetName . replace ( / ^ _ + | _ + $ / g, "" ) . length === 0 ; //all whitespace names are rejected
263+ if ( noPresetName ) {
264+ Notifications . add ( "Preset name cannot be empty" , 0 ) ;
265+ return ;
266+ }
264267
265- if ( presetNameEl ?. getValidationResult ( ) . status === "failed" ) {
266- Notifications . add ( "Preset name is not valid" , 0 ) ;
267- return ;
268+ if ( presetNameEl ?. getValidationResult ( ) . status === "failed" ) {
269+ Notifications . add ( "Preset name is not valid" , 0 ) ;
270+ return ;
271+ }
268272 }
269273
270274 hide ( ) ;
You can’t perform that action at this time.
0 commit comments