Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: floating code popup #39885

Open
wants to merge 8 commits into
base: release
Choose a base branch
from

Conversation

alex-golovanov
Copy link
Contributor

@alex-golovanov alex-golovanov commented Mar 24, 2025

Description

Pop-up editor for property pane.

Fixes #34541

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14079811857
Commit: 3f357d3
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.js
  2. cypress/e2e/Regression/ClientSide/IDE/Canvas_Context_Property_Pane_2_spec.js
List of identified flaky tests.
Wed, 26 Mar 2025 11:16:34 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a draggable, resizable pop-out code editor that offers a flexible, expanded editing mode.
    • Enhanced the main code editor with an expand trigger for a seamless switch between inline and pop-out views.
    • Added a new pop-out editor feature to the InputText component for improved interactivity.
  • Style

    • Updated the visual design and layout of the pop-out interface to ensure a consistent and user-friendly experience.

@alex-golovanov alex-golovanov requested review from a team and KelvinOm as code owners March 24, 2025 14:43
@alex-golovanov alex-golovanov requested review from vivek-appsmith and removed request for a team March 24, 2025 14:43
Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

Walkthrough

This change introduces a floating code popup for the property pane. A new dependency (react-rnd) has been added to enable draggable and resizable functionality. The implementation includes a new PopoutEditor component with supporting constants, styles, and an export for reuse. Additionally, existing components (CodeEditor and CodeEditorControl) have been updated to support an expand trigger that toggles between a standard editor view and the new popup interface.

Changes

File(s) Change Summary
app/client/package.json Added dependency "react-rnd": "^10.5.2".
app/client/src/components/editorComponents/CodeEditor/PopoutEditor/* Introduced new PopoutEditor component, associated constants, styles, and export for a draggable/resizable code editor popup.
app/client/src/components/editorComponents/CodeEditor/index.tsx Updated CodeEditor to include an expand trigger with a tooltip and icon button; extended the EditorStyleProps interface.
app/client/src/components/propertyControls/CodeEditorControl.tsx Modified to add a popOutVisible state and onExpanded method for toggling between the standard and pop-out editor views.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant U as User
    participant CE as CodeEditor
    participant CEC as CodeEditorControl
    participant PE as PopoutEditor

    U->>CE: Click expand trigger
    CE->>CEC: Invoke onExpandTriggerClick
    CEC->>CEC: Set popOutVisible=true
    CEC->>PE: Render PopoutEditor with props
    PE->>PE: Initialize draggable & resizable functionality
    PE->>CEC: onClose event when user closes popup
    CEC->>CEC: Set popOutVisible=false

Assessment against linked issues

Objective Addressed Explanation
Floating code popup for property pane (#34541)

Poem

In our code, a popup now takes flight,
Draggable dreams dancing in the light.
Resizable windows open wide and clear,
Expanding our view, bringing ideas near.
A code adventure awaits with every click—
Happy coding, nimble and quick!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 909e4e8 and 233c651.

⛔ Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • app/client/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/package.json
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build

🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

Documentation and Community

  • 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: 3

🧹 Nitpick comments (5)
app/client/src/components/editorComponents/CodeEditor/index.tsx (1)

1732-1745: Good implementation of the expand trigger.

The expand trigger is implemented with appropriate conditional rendering and accessibility features:

  1. Uses a Tooltip for better UX
  2. Proper button kind and icon choice
  3. Correctly passes the click handler

One minor suggestion: consider adding an aria-label for better accessibility.

<Button
  className="commands-button invisible"
  isIconButton
  kind="secondary"
  onClick={this.props.onExpandTriggerClick}
  size="sm"
  startIcon="external-link-line"
+  aria-label="Expand code editor"
/>
app/client/src/components/propertyControls/CodeEditorControl.tsx (1)

46-76: Consider enhancing the placeholder UI.

The Flex component rendered when popOutVisible is true serves as a placeholder but doesn't provide users with context about the expanded state. Consider adding text or an icon to indicate that an editor is currently expanded.

<Flex
  alignItems="center"
  bg="var(--ads-v2-color-bg)"
  border="1px solid var(--ads-v2-color-border)"
  borderRadius="var(--ads-v2-border-radius)"
  h="36px"
  justifyContent="center"
  w="100%"
>
+  <Text kind="body-s">Editor expanded in floating window</Text>
</Flex>
app/client/src/components/editorComponents/CodeEditor/PopoutEditor/PopoutEditor.tsx (3)

77-82: Use destructured value for consistency

In the x calculation, you're using defaultWith directly from the destructured variables, but in the window width calculation you reference it indirectly. Update for consistency.

return {
-  x: Math.max((window.innerWidth - defaultWith) / 2, 0),
+  x: Math.max((window.innerWidth - defaultWidth) / 2, 0),
  y: Math.max((window.innerHeight - defaultHeight) / 2, 0),
  width: defaultWith,
  height: defaultHeight,
};

93-95: Consider using a more descriptive debounce timeout constant name

The constant name RESIZE_DEBOUNCE_TIMEOUT is generic. Consider renaming it to something more specific like EDITOR_RESIZE_DEBOUNCE_TIMEOUT to clarify its purpose.


44-55: Consider making required props explicit

The PopoutEditorProps interface extends Partial<EditorProps> which makes all EditorProps optional, but then explicitly requires some props. Consider using a more specific approach.

-export interface PopoutEditorProps extends Partial<EditorProps> {
+export interface PopoutEditorProps {
+  // Required props
  additionalAutocomplete?: AdditionalDynamicDataTree;
  dataTreePath?: string;
  expected?: CodeEditorExpected;
  hideEvaluatedValue?: boolean;
  label: string;
  onChange: EventOrValueHandler<ChangeEvent<HTMLTextAreaElement>>;
  onClose: () => void;
  theme: EditorTheme;
  value: string;
  widgetName: string;
+  // Optional EditorProps
+  [key: string]: any; // Or list specific EditorProps you need
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbf2e2d and 9035e83.

⛔ Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (7)
  • app/client/package.json (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/PopoutEditor/PopoutEditor.tsx (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/PopoutEditor/constants.ts (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/PopoutEditor/index.ts (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/PopoutEditor/styles.ts (1 hunks)
  • app/client/src/components/editorComponents/CodeEditor/index.tsx (3 hunks)
  • app/client/src/components/propertyControls/CodeEditorControl.tsx (2 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
app/client/src/components/propertyControls/CodeEditorControl.tsx (2)
app/client/src/components/editorComponents/CodeEditor/index.tsx (1)
  • EditorProps (227-266)
app/client/src/components/editorComponents/CodeEditor/PopoutEditor/PopoutEditor.tsx (1)
  • PopoutEditor (57-183)
app/client/src/components/editorComponents/CodeEditor/PopoutEditor/PopoutEditor.tsx (2)
app/client/src/components/editorComponents/CodeEditor/index.tsx (2)
  • EditorProps (227-266)
  • CodeEditorExpected (169-174)
app/client/src/components/editorComponents/CodeEditor/PopoutEditor/constants.ts (5)
  • RND_CONFIG (15-21)
  • RESIZE_DEBOUNCE_TIMEOUT (23-23)
  • DRAG_HANDLE_CLASS_NAME (12-12)
  • RESIZE_HANDLE_STYLES (1-10)
  • RESIZE_HANDLE_CLASS_NAME (13-13)
🔇 Additional comments (13)
app/client/src/components/editorComponents/CodeEditor/PopoutEditor/index.ts (1)

1-2: Clean export implementation.

This export statement properly exposes the PopoutEditor component from its implementation file, following standard module export patterns.

app/client/package.json (1)

196-196: Appropriate dependency addition.

The react-rnd package is a good choice for implementing draggable and resizable UI elements. Version 10.5.2 is stable and compatible with the existing React version.

app/client/src/components/editorComponents/CodeEditor/index.tsx (2)

77-77: Proper import for button components.

The necessary UI components for the expand functionality are correctly imported from the design system.


187-190: Well-structured interface extension.

The added properties to the EditorStyleProps interface clearly define the contract for the expand functionality with appropriate optional flags.

app/client/src/components/propertyControls/CodeEditorControl.tsx (3)

15-16: Appropriate component imports.

The PopoutEditor and Flex components are correctly imported for implementing the floating editor functionality.


19-25: Clean state management implementation.

Good implementation of state management for the popup visibility with a clear state setter method.


77-87: Well-implemented PopoutEditor integration.

The PopoutEditor is properly implemented with all necessary props passed through. The onClose handler correctly resets the state when the popup is closed.

app/client/src/components/editorComponents/CodeEditor/PopoutEditor/styles.ts (4)

3-14: LGTM: Backdrop implementation with correct pointer events

The Backdrop component correctly uses pointer-events: none to allow interaction with elements beneath it while providing visual context.


16-29: LGTM: Well-structured PopoutContainer with proper styling

The PopoutContainer properly sets pointer-events: auto to re-enable mouse events within the container, with appropriate z-index levels to ensure proper layering.


31-40: LGTM: Header with proper drag functionality settings

The header component correctly implements styles needed for the drag functionality, including cursor: move and user-select: none to prevent text selection while dragging.


42-51: LGTM: EditorContainer with appropriate CodeMirror styling

The EditorContainer properly manages overflow and whitespace styles, with specific styling for CodeMirror to preserve whitespace as needed.

app/client/src/components/editorComponents/CodeEditor/PopoutEditor/PopoutEditor.tsx (2)

102-121: LGTM: Efficient use of ResizeObserver with proper cleanup

Good implementation of ResizeObserver to track container size changes, with proper cleanup in the useLayoutEffect hook.


127-182: LGTM: Well-structured portal implementation with proper component composition

The portal implementation is well-structured with appropriate component composition. The use of the Rnd component for draggable and resizable functionality is implemented correctly.

@KelvinOm KelvinOm requested review from jsartisan and removed request for KelvinOm March 24, 2025 19:15
@jsartisan
Copy link
Contributor

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14056585913.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39885.
recreate: .

@github-actions github-actions bot added IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo Enhancement New feature or request labels Mar 25, 2025
@alex-golovanov alex-golovanov added the ok-to-test Required label for CI label Mar 25, 2025
@alex-golovanov
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14067684915.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39885.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-39885.dp.appsmith.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request IDE Navigation Issues/feature requests related to IDE navigation, and context switching IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Add floating code popup for property pane
3 participants