Skip to content

Conversation

@devtools-boxfusion
Copy link
Collaborator

@devtools-boxfusion devtools-boxfusion commented Aug 12, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Text component now displays a default placeholder (“Text...”) when content is missing, preventing empty text blocks after updates or imports.
    • Improves consistency of existing designs by preserving current content where available and only filling gaps when needed.
  • Chores

    • Internal migration improvements to ensure smoother upgrades with no impact on public APIs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Walkthrough

Adds a new migrator step (index 6) in shesha-reactjs TextComponent to set a default content value ("Text...") when content is undefined or null, placed after the existing font size adjustment step. No exported/public API changes.

Changes

Cohort / File(s) Summary of Changes
TextComponent Migrator Updates
shesha-reactjs/src/designer-components/text/index.tsx
Inserted migrator step at index 6 to set content to prev.content ?? "Text...", preserving existing content. Positioned after font-size migration (index 5). No other migrator steps or public interfaces changed.

Sequence Diagram(s)

sequenceDiagram
  participant Designer as App Designer
  participant Migrator as TextComponent Migrator
  participant Step5 as Step 5: Font Size Adjust
  participant Step6 as Step 6: Default Content

  Designer->>Migrator: Load existing Text props
  Migrator->>Step5: Apply font-size migration
  Step5-->>Migrator: Updated props
  Migrator->>Step6: Apply default content (content ?? "Text...")
  Step6-->>Migrator: Updated props
  Migrator-->>Designer: Migrated Text props
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • James/b/text #3645: Also edits the TextComponent migrator, adding a font-size conversion step in the same file.
  • Tshepo/f/text #3107: Adjusts the TextComponent migrator to pass prev.textType into defaultStyles in the same module.

Suggested reviewers

  • James-Baloyi

Poem

A hop, a skip, a tiny edit made—
When content’s missing, “Text...” comes to aid.
I twitch my ears at index six,
Ensuring blanks get gentle fix.
Thump-thump! The migrator’s path is set—
A tidy field, no nulls to fret. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
shesha-reactjs/src/designer-components/text/index.tsx (3)

90-91: Localize or centralize the default string

Hardcoding "Text..." in English may conflict with localization. Consider sourcing from your i18n layer or a shared constant (e.g., DEFAULT_TEXT_CONTENT) for consistency.

If you confirm the preferred i18n mechanism (e.g., react-intl, i18next, or your internal utility), I can propose a concrete patch.


90-91: Nit: align with repo quote style

Use single quotes to match the surrounding file’s style.

Apply this minimal diff:

-      .add<ITextTypographyProps>(6, (prev) => ({ ...prev, content: prev.content ?? "Text..." }))
+      .add<ITextTypographyProps>(6, (prev) => ({ ...prev, content: prev.content ?? 'Text...' }))

90-91: Verify default content in initModel for new Text components

I wasn’t able to locate a content: 'Text...' default in the initModel block of shesha-reactjs/src/designer-components/text/index.tsx. To ensure newly added Text components show the placeholder immediately (even if migrators haven’t run), seed the default there before spreading in the user model.

• File: shesha-reactjs/src/designer-components/text/index.tsx
• Add or confirm in the initModel block:

initModel: (model) => ({
  /* other defaults */
  content: 'Text...',   // default for new instances
  ...model,
}),

Please verify and add this if it’s missing.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd20115 and 71bbb0c.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/text/index.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: teboho
PR: shesha-io/shesha-framework#3397
File: shesha-reactjs/src/designer-components/charts/bar.tsx:49-52
Timestamp: 2025-06-12T16:55:57.638Z
Learning: For the chart components’ migrators (e.g., BarChartComponent in shesha-reactjs/src/designer-components/charts/bar.tsx), the version 5 step intentionally spreads `{ ...prev, ...defaultConfigFiller }` so that values from `defaultConfigFiller` override any existing properties in `prev`. This reset to new defaults is by design and should not be flagged as an issue.
📚 Learning: 2025-06-12T16:55:57.638Z
Learnt from: teboho
PR: shesha-io/shesha-framework#3397
File: shesha-reactjs/src/designer-components/charts/bar.tsx:49-52
Timestamp: 2025-06-12T16:55:57.638Z
Learning: For the chart components’ migrators (e.g., BarChartComponent in shesha-reactjs/src/designer-components/charts/bar.tsx), the version 5 step intentionally spreads `{ ...prev, ...defaultConfigFiller }` so that values from `defaultConfigFiller` override any existing properties in `prev`. This reset to new defaults is by design and should not be flagged as an issue.

Applied to files:

  • shesha-reactjs/src/designer-components/text/index.tsx
📚 Learning: 2025-06-10T11:52:51.462Z
Learnt from: teboho
PR: shesha-io/shesha-framework#3374
File: shesha-reactjs/src/generic-pages/settings/dynamic-theme/textsExample.tsx:13-15
Timestamp: 2025-06-10T11:52:51.462Z
Learning: In the Shesha framework's dynamic theme system, the "Global text" Typography element in textsExample.tsx is intentionally left without explicit styling to demonstrate automatic global text color application through the ConfigProvider's colorText token, while the "Default text" element uses explicit theme color styling to show the difference between global and default text color approaches.

Applied to files:

  • shesha-reactjs/src/designer-components/text/index.tsx
🔇 Additional comments (1)
shesha-reactjs/src/designer-components/text/index.tsx (1)

90-91: Sensible defaulting: preserves intentional empty strings and only backfills null/undefined

Using nullish coalescing here is correct and safely avoids overwriting empty string content. Placement after the font-size step is fine. This aligns with prior learnings where migrators resetting defaults is intentional; this change is even safer by only filling nullish values.

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.

1 participant