Skip to content

Conversation

@niko-exo
Copy link

@niko-exo niko-exo commented Dec 24, 2025

ref: https://app.clickup.com/t/86b7h9kmt

86b7h9kmt - fix: replace hidden html string for empty string

Changelog

  • Validate html dirty string and replace its value for an empty string to trigger validation.

Links

86b7h9kmt - User is able to save without filling out mandatory field

Evidence

2025-12-24_11-06-02.mp4

Summary by CodeRabbit

  • Bug Fixes
    • Text editor now correctly recognizes and clears empty content (e.g., editor empty HTML becomes an empty value) so form submission and field state behave as expected.
  • Tests
    • Added unit tests to validate empty vs. non-empty editor content normalization.

✏️ Tip: You can customize this high-level summary in your review settings.

@niko-exo
Copy link
Author

niko-exo commented Jan 5, 2026

@smarcet Don't forget about this PR.

Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@niko-exo please review commnets

@niko-exo niko-exo force-pushed the fix/validate-description-field-on-item-creation branch from 0237caf to 1b497e8 Compare January 19, 2026 12:23
@coderabbitai
Copy link

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

The Formik text editor's onChange now routes the editor HTML through a new normalizeJoditEmpty utility which returns an empty string for empty-like HTML; that normalized value is then used to update the Formik field.

Changes

Cohort / File(s) Summary
Formik component change
src/components/inputs/formik-text-editor.js
Import and call normalizeJoditEmpty in the editor's onChange handler so the value passed to Formik is normalized (empty-like HTML → "") before calling setFieldValue.
New utility + tests
src/components/inputs/utils/normalizeJoditEmpty.js, src/components/inputs/utils/__tests__/normalizeJoditEmpty.test.js
Add normalizeJoditEmpty (parses HTML and returns "" when body text is empty) and accompanying unit tests verifying empty-like HTML normalizes to "" and non-empty HTML remains unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Editor as JoditEditor
    participant Norm as normalizeJoditEmpty
    participant Formik

    User->>Editor: type / edit content
    Editor->>Editor: produce HTML string (e.g. "<p><br></p>")
    Editor->>Norm: onChange -> pass HTML
    Norm-->>Editor: return "" or original HTML
    Editor->>Formik: setFieldValue(normalizedValue)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I nibbled tags in the editor light,
Trimmed tiny <p><br></p> out of sight,
"Empty no more!" the field did sing,
Now forms are tidy — hop, spring! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: introducing a utility to normalize empty Jodit HTML strings to actual empty strings for validation purposes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@niko-exo
Copy link
Author

Rebase based on master performed on branch and changes force pushed.

id={name}
value={values[name]}
onChange={(e) => setFieldValue(name, e.target.value)}
onChange={(e) => {
Copy link

@smarcet smarcet Jan 19, 2026

Choose a reason for hiding this comment

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

@niko-exo seems that comment got truncated
let move this to an util method and lets take care of following corner cases
const normalizeJoditEmpty = (html) => { if (!html) return ""; const v = html.trim(); return (v === "<p><br></p>" || v === "<p><br/></p>" || v === "<p>&nbsp;</p>" || v === "<p></p>") ? "" : html; };

@niko-exo
Copy link
Author

@smarcet Checkout the new implementation I've done. Seems to cover all cases you mentioned and more.

Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

LGTM

@smarcet smarcet merged commit cd303a7 into master Jan 19, 2026
9 checks passed
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.

3 participants