@@ -396,6 +396,38 @@ define(function (require, exports, module) {
396396 const hasAbbr = $abbrInput . val ( ) . trim ( ) . length > 0 ;
397397 const hasTemplate = $templateInput . val ( ) . trim ( ) . length > 0 ;
398398 $saveBtn . prop ( "disabled" , ! ( hasAbbr && hasTemplate ) ) ;
399+
400+ // Also toggle the reset button state
401+ toggleResetButtonDisability ( ) ;
402+ }
403+
404+ /**
405+ * This function checks if the snippet is in its default state and
406+ * disables the reset button if it is
407+ */
408+ function toggleResetButtonDisability ( ) {
409+ const $editView = $ ( "#custom-snippets-edit" ) ;
410+ const originalSnippet = $editView . data ( "originalSnippet" ) ;
411+ const $resetBtn = $ ( "#reset-snippet-btn" ) ;
412+
413+ if ( ! originalSnippet ) {
414+ // If there's no original snippet data, disable the reset button
415+ $resetBtn . prop ( "disabled" , true ) ;
416+ return ;
417+ }
418+
419+ // Get current values from the form
420+ const currentData = getEditSnippetData ( ) ;
421+
422+ // Check if current values match original values
423+ const isDefault =
424+ currentData . abbreviation === originalSnippet . abbreviation &&
425+ currentData . description === ( originalSnippet . description || "" ) &&
426+ currentData . templateText === originalSnippet . templateText &&
427+ currentData . fileExtension === originalSnippet . fileExtension ;
428+
429+ // Disable reset button if in default state
430+ $resetBtn . prop ( "disabled" , isDefault ) ;
399431 }
400432
401433 /**
@@ -769,6 +801,7 @@ define(function (require, exports, module) {
769801 exports . populateEditForm = populateEditForm ;
770802 exports . getEditSnippetData = getEditSnippetData ;
771803 exports . toggleEditSaveButtonDisability = toggleEditSaveButtonDisability ;
804+ exports . toggleResetButtonDisability = toggleResetButtonDisability ;
772805 exports . clearEditInputFields = clearEditInputFields ;
773806 exports . handleTextareaTabKey = handleTextareaTabKey ;
774807 exports . validateAbbrInput = validateAbbrInput ;
0 commit comments