Skip to content

Conversation

@paulinewahle
Copy link
Contributor

@paulinewahle paulinewahle commented Sep 24, 2024

fix: #1859

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

Summary by CodeRabbit

  • New Features

    • Replaced the plain text input with an integrated code editor for JSON editing, including syntax highlighting, line numbers, linting, and code folding.
  • Style

    • Removed the previous fixed height; the new editor now adapts dynamically with a capped maximum height for better layout behavior.

@github-actions
Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3199/

@paulinewahle paulinewahle self-assigned this Sep 24, 2024

public render() {
return [
<textarea onChange={this.handleTextChange}>{this.text}</textarea>,
Copy link
Contributor

Choose a reason for hiding this comment

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

in the previous version, one could typ inside the textarea and see the results live in the form below. We should make sure that the same thing happens when using the code-editor

Copy link
Contributor

Choose a reason for hiding this comment

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

On testing it doesn't seem to update live in the form below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Screen.Recording.2025-08-11.at.13.45.29.mov

it seems that the form updates are 1 character behind the actual input of the code editor 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

it's OK to just close the issue and PR too. This is only in the documentations and we don't have to spend time on fixing it. The equation of the efforts versus value added, is a bit questionable 😅

@paulinewahle paulinewahle force-pushed the dynamic-schema-code-editor branch 3 times, most recently from 33be529 to 1b6d8f8 Compare September 24, 2024 12:14
@adrianschmidt adrianschmidt force-pushed the main branch 3 times, most recently from 197298f to a0e1088 Compare February 13, 2025 18:06
@adrianschmidt
Copy link
Contributor

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Replaces a textarea with a limel-code-editor in the dynamic form example and updates accompanying CSS to target the new element and set a max height via a CSS custom property.

Changes

Cohort / File(s) Change Summary
Example stylesheet
src/components/form/examples/dynamic-form.scss
Selector changed from textarealimel-code-editor; added --code-editor-max-height: 20rem; removed min-height: 300px; kept width: 100%.
Example component
src/components/form/examples/dynamic-form.tsx
Replaced <textarea> with <limel-code-editor language="json" lineNumbers={true} lint={true} fold={true}>; updated onChange handler to read event.detail for value assignment; render value bound to this.text.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DynamicForm
    participant CodeEditor as limel-code-editor

    User ->> CodeEditor: Edit JSON
    CodeEditor -->> DynamicForm: onChange (event.detail)
    DynamicForm ->> CodeEditor: Update value (this.text)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective (issue) Addressed Explanation
Use limel-code-editor instead of textarea in form example [#1859]

Out-of-scope changes

(No out-of-scope changes detected.)

Suggested labels

maintenance

Suggested reviewers

  • jgroth
  • LucyChyzhova
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dynamic-schema-code-editor

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.

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.

@adrianschmidt adrianschmidt force-pushed the dynamic-schema-code-editor branch from 1b6d8f8 to b8ebf82 Compare March 2, 2025 15:44
Copy link

@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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b6d8f8 and b8ebf82.

📒 Files selected for processing (2)
  • src/components/form/examples/dynamic-form.scss (1 hunks)
  • src/components/form/examples/dynamic-form.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/form/examples/dynamic-form.scss
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/form/examples/dynamic-form.tsx

[error] 48-55: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Docs / Publish Docs
  • GitHub Check: Test
  • GitHub Check: Build
🔇 Additional comments (2)
src/components/form/examples/dynamic-form.tsx (2)

48-55: Great improvement using limel-code-editor instead of textarea

Replacing the textarea with a code editor provides a better user experience for editing JSON, with features like syntax highlighting, line numbers, linting, and code folding.

🧰 Tools
🪛 Biome (1.9.4)

[error] 48-55: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


72-82:

Details

❓ Verification inconclusive

Verify handling of event.target.value with limel-code-editor

The code editor component might emit events with a different structure than a standard textarea. Please verify that event.target.value still correctly accesses the edited content.


🏁 Script executed:

#!/bin/bash
# Search for other usages of limel-code-editor to see how the onChange event is typically handled
rg --type ts "limel-code-editor.*onChange"

# Also search for the implementation of limel-code-editor to understand its event structure
fd -e ts -e tsx "code-editor" src/components/

Length of output: 432


Action: Confirm correct event property for limel-code-editor events

At src/components/form/examples/dynamic-form.tsx (lines 72–82), the handleTextChange method currently accesses the edited content via event.target.value. Since the limel-code-editor component may emit a custom event structure—potentially using a property like event.detail instead of the conventional target.value—please verify that the current usage correctly retrieves the updated content. If the event structure deviates from that of a standard textarea, update the handler accordingly to ensure the proper value is captured.

@Lundalogik Lundalogik deleted a comment from paulinewahle Aug 11, 2025
Comment on lines 1 to 4
limel-code-editor {
width: 100%;
min-height: 300px;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
limel-code-editor {
width: 100%;
min-height: 300px;
}
limel-code-editor {
--code-editor-max-height: 20rem;
}

@Kiarokh Kiarokh changed the title fix(dynamic-form): change example from textarea to code-editor @coderabbitai Aug 11, 2025
Copilot AI review requested due to automatic review settings August 11, 2025 09:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces a basic textarea with a custom code editor component for JSON editing in the dynamic form example. The change enhances the user experience by providing advanced features like syntax highlighting, line numbering, linting, and code folding for better JSON editing capabilities.

Key changes:

  • Replaced <textarea> with <limel-code-editor> component configured for JSON
  • Updated event handling to use the new component's event structure
  • Modified styling to accommodate the new editor component

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/form/examples/dynamic-form.tsx Replaces textarea with limel-code-editor and updates event handling
src/components/form/examples/dynamic-form.scss Updates CSS selector and properties for the new code editor component

this.text = event.target.value;
this.text = event.detail;
try {
const json = JSON.parse(event.target.value);
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The code is trying to parse event.target.value but the event handling was changed to use event.detail on line 73. This should be JSON.parse(this.text) or JSON.parse(event.detail) to be consistent with the new event structure.

Suggested change
const json = JSON.parse(event.target.value);
const json = JSON.parse(event.detail);

Copilot uses AI. Check for mistakes.
@coderabbitai coderabbitai bot changed the title @coderabbitai Use limel-code-editor in dynamic form example; update CSS max height Aug 11, 2025
Copy link

@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: 1

♻️ Duplicate comments (1)
src/components/form/examples/dynamic-form.tsx (1)

72-76: Fix change handler: parse JSON from event.detail (root cause of “no live update”)

limel-code-editor emits the new value in event.detail. Parsing event.target.value leaves schema unchanged, breaking live updates.

Apply this diff:

-    private handleTextChange = (event) => {
-        this.text = event.detail;
-        try {
-            const json = JSON.parse(event.target.value);
-            if (json) {
-                this.schema = json;
-            }
-        } catch (e) {
-            console.log(e);
-        }
-    };
+    private handleTextChange = (event: CustomEvent<string>) => {
+        const value = event.detail;
+        this.text = value;
+        try {
+            const parsed = JSON.parse(value);
+            if (parsed && typeof parsed === 'object') {
+                this.schema = parsed as FormSchema;
+            }
+        } catch (e) {
+            console.log(e);
+        }
+    };

Please verify: typing valid JSON in the editor updates the form below in real time.

Also applies to: 72-82

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8ebf82 and d5eb982.

📒 Files selected for processing (2)
  • src/components/form/examples/dynamic-form.scss (1 hunks)
  • src/components/form/examples/dynamic-form.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/components/**/*.scss

📄 CodeRabbit Inference Engine (.cursor/rules/css-class-names-in-components-using-shadow-dom.mdc)

Do not use BEM-style class names in CSS for components, as components use shadow-DOM.

Files:

  • src/components/form/examples/dynamic-form.scss
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/wrap-multiple-jsx-elements-in-host-not-in-array.mdc)

When returning multiple JSX elements from the render method, never wrap them in an array literal. Instead, always wrap them in the special <Host> element. When there is already a single top-level element, it does not have to be wrapped in <Host>.

Files:

  • src/components/form/examples/dynamic-form.tsx
src/components/**/*.tsx

⚙️ CodeRabbit Configuration File

When contributors add new props to existing components in the lime-elements repository, they should always add documentation examples that demonstrate the new prop's usage and explain how it works. This helps with user adoption, feature discoverability, and maintains comprehensive documentation.

Files:

  • src/components/form/examples/dynamic-form.tsx
🧠 Learnings (2)
📚 Learning: 2025-04-25T13:32:56.396Z
Learnt from: adrianschmidt
PR: Lundalogik/lime-elements#3529
File: src/components/lime-ai-avatar/lime-ai-avatar.tsx:30-38
Timestamp: 2025-04-25T13:32:56.396Z
Learning: For StencilJS components in lime-elements, prefer using the `<Host>` element to wrap child elements in the render method instead of returning an array of elements. This follows the standard pattern in the codebase and eliminates the need for key attributes.

Applied to files:

  • src/components/form/examples/dynamic-form.tsx
📚 Learning: 2025-04-25T13:32:56.396Z
Learnt from: adrianschmidt
PR: Lundalogik/lime-elements#3529
File: src/components/lime-ai-avatar/lime-ai-avatar.tsx:30-38
Timestamp: 2025-04-25T13:32:56.396Z
Learning: For StencilJS components in lime-elements, prefer using the `<Host>` element to wrap child elements in the render method instead of returning an array of elements, which eliminates the need for key attributes and follows StencilJS best practices.

Applied to files:

  • src/components/form/examples/dynamic-form.tsx
🪛 Biome (2.1.2)
src/components/form/examples/dynamic-form.tsx

[error] 48-55: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Docs / Publish Docs
  • GitHub Check: Build
  • GitHub Check: Test
🔇 Additional comments (1)
src/components/form/examples/dynamic-form.scss (1)

1-4: LGTM: styles aligned with limel-code-editor

Using a CSS custom property for max height is appropriate and keeps styling encapsulated.

@paulinewahle paulinewahle force-pushed the dynamic-schema-code-editor branch 2 times, most recently from 03df1fa to 32ffb35 Compare August 12, 2025 12:48
@paulinewahle paulinewahle requested a review from Kiarokh August 12, 2025 12:49
Comment on lines 49 to 67
<limel-code-editor
language="json"
lineNumbers={true}
lint={true}
fold={true}
onChange={this.handleTextChange}
value={this.text}
/>
,
<br />,
<limel-form
onChange={this.handleFormChange}
onValidate={this.handleValidate}
value={this.formData}
schema={this.schema}
/>
,
<limel-example-value value={this.formData} />,
<limel-example-value label="Errors" value={this.errors} />,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<limel-code-editor
language="json"
lineNumbers={true}
lint={true}
fold={true}
onChange={this.handleTextChange}
value={this.text}
/>
,
<br />,
<limel-form
onChange={this.handleFormChange}
onValidate={this.handleValidate}
value={this.formData}
schema={this.schema}
/>
,
<limel-example-value value={this.formData} />,
<limel-example-value label="Errors" value={this.errors} />,
<limel-code-editor
language="json"
lineNumbers={true}
lint={true}
fold={true}
onChange={this.handleTextChange}
value={this.text}
/>
<br />
<limel-form
onChange={this.handleFormChange}
onValidate={this.handleValidate}
value={this.formData}
schema={this.schema}
/>
<limel-example-value value={this.formData} />
<limel-example-value label="Errors" value={this.errors} />

The commas aren't needed anymore, and if kept, they'll render in the DOM as ,s

@paulinewahle paulinewahle force-pushed the dynamic-schema-code-editor branch from 318a861 to d75083c Compare August 12, 2025 13:04
@paulinewahle paulinewahle requested a review from Kiarokh August 12, 2025 13:04
this.text = event.detail;
try {
const json = JSON.parse(event.target.value);
const json = JSON.parse(event.detail);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kiarokh I redefined this to fix the lagging render issue in the last fixup

@Kiarokh Kiarokh merged commit 15720ce into main Aug 12, 2025
12 checks passed
@Kiarokh Kiarokh deleted the dynamic-schema-code-editor branch August 12, 2025 14:13
@lime-opensource
Copy link
Collaborator

🎉 This PR is included in version 38.21.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOCS: use limel-code-editor instead of textarea in form example

6 participants