Skip to content

Conversation

@pierluca
Copy link
Contributor

@pierluca pierluca commented Nov 18, 2025

Note

Class form now disables the save button when there are no changes or during/after submit, resets dirty state post-success, and shows a tooltip; minor spacing tweak.

  • ClassForm (frontend/src/components/class/ClassForm.tsx):
    • Submit behavior:
      • Disable SubmitFormButton when editing with no changes, while submitting, or after successful submit.
      • Add tooltip message when disabled due to no changes.
      • Reset form dirty state on successful submit while keeping current values (preserves edited badges logic).
    • UI:
      • Add top margin to button wrapper for spacing.

Written by Cursor Bugbot for commit d6c5979. This will update automatically on new commits. Configure here.


Summary by cubic

Prevents duplicate class creation by disabling the Save button when there are no changes and during/after submit. Addresses CRT-212 and adds a small UI tweak for clarity.

  • Bug Fixes
    • Disable submit when form is not dirty, is submitting, or just submitted.
    • Show “No changes to save” tooltip when disabled due to no changes.
    • After successful submit in edit mode, reset form state (keep values, clear dirty) to avoid accidental resubmits.
    • Add top margin to the button area for better spacing.

Written for commit 1215b48. Summary will update automatically on new commits.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

isDirty
? undefined
: intl.formatMessage(messages.disabledSaveButtonTooltip)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Button Tooltip: Wrong Reason for Disabled State

The tooltip displays "No changes to save" whenever isDirty is false, but the button is also disabled during form submission (isSubmitting) and after successful submission (isSubmitSuccessful). In those cases, the tooltip message is misleading since the button isn't disabled due to lack of changes.

Fix in Cursor Fix in Web

…ion' into feature/CRT-212_UpdateCreateClassFlow
@pierluca pierluca merged commit f868ccd into feature/CRT-197_ChakraUIIntegration Nov 18, 2025
1 of 2 checks passed
@pierluca pierluca deleted the feature/CRT-212_UpdateCreateClassFlow branch November 18, 2025 19:14
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="frontend/src/components/class/ClassForm.tsx">

<violation number="1" location="frontend/src/components/class/ClassForm.tsx:106">
Save button still re-enables in create mode because the disable logic only checks `!isDirty` when `showEditedBadges` is true, so after `reset(values)` the button becomes clickable again and users can submit duplicate classes—this violates CRT-212’s “disable when no changes” requirement.</violation>

<violation number="2" location="frontend/src/components/class/ClassForm.tsx:150">
Removing the `&lt;Field.ErrorText&gt;` when self-closing the teacher `&lt;Select&gt;` means `errors.teacherId?.message` is never rendered, so users no longer see why submission fails when the teacher field is missing.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

>
<Field.ErrorText>{errors.teacherId?.message}</Field.ErrorText>
</Select>
/>
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the <Field.ErrorText> when self-closing the teacher <Select> means errors.teacherId?.message is never rendered, so users no longer see why submission fails when the teacher field is missing.

Prompt for AI agents
Address the following comment on frontend/src/components/class/ClassForm.tsx at line 150:

<comment>Removing the `&lt;Field.ErrorText&gt;` when self-closing the teacher `&lt;Select&gt;` means `errors.teacherId?.message` is never rendered, so users no longer see why submission fails when the teacher field is missing.</comment>

<file context>
@@ -120,15 +147,21 @@ const ClassForm = ({
-                &gt;
-                  &lt;Field.ErrorText&gt;{errors.teacherId?.message}&lt;/Field.ErrorText&gt;
-                &lt;/Select&gt;
+                /&gt;
               &lt;/Field.Root&gt;
             &lt;/GridItem&gt;
</file context>
Fix with Cubic


// Disable the button if in edit mode with no changes, or if the form is submitting or has been successfully submitted
const isButtonDisabled =
(showEditedBadges && !isDirty) || isSubmitSuccessful || isSubmitting;
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save button still re-enables in create mode because the disable logic only checks !isDirty when showEditedBadges is true, so after reset(values) the button becomes clickable again and users can submit duplicate classes—this violates CRT-212’s “disable when no changes” requirement.

Prompt for AI agents
Address the following comment on frontend/src/components/class/ClassForm.tsx at line 106:

<comment>Save button still re-enables in create mode because the disable logic only checks `!isDirty` when `showEditedBadges` is true, so after `reset(values)` the button becomes clickable again and users can submit duplicate classes—this violates CRT-212’s “disable when no changes” requirement.</comment>

<file context>
@@ -80,9 +99,17 @@ const ClassForm = ({
 
+  // Disable the button if in edit mode with no changes, or if the form is submitting or has been successfully submitted
+  const isButtonDisabled =
+    (showEditedBadges &amp;&amp; !isDirty) || isSubmitSuccessful || isSubmitting;
+
+  type TeacherOption = {
</file context>
Suggested change
(showEditedBadges && !isDirty) || isSubmitSuccessful || isSubmitting;
!isDirty || isSubmitSuccessful || isSubmitting;
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants