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

chore: fix custom widget height issue #39428

Merged
merged 3 commits into from
Feb 25, 2025

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Feb 25, 2025

Fixes #39406

/test Widgets

Summary by CodeRabbit

  • New Features

    • Custom widget now adjusts its height dynamically, improving responsiveness during resizing.
  • Refactor

    • Enhanced and simplified height calculation for both standard and embed modes for a more consistent display.
  • Chores

    • Updated the AI Bot endpoint to align with the current development environment.

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13516801371
Commit: fa729e7
Cypress dashboard.
Tags: @tag.Widget
Spec:


Tue, 25 Feb 2025 09:41:37 UTC

Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

Walkthrough

The pull request enhances the custom widget’s height management. In the main hook, the logic now returns immediately if the canvas element is missing and introduces an updateHeight function. A ResizeObserver is added to adjust the height dynamically during canvas resizing, with proper cleanup on component unmount. Additionally, the helper function for height calculation is simplified by removing the calc wrapper, and an AI bot URL constant is updated to a development endpoint with the previous URL commented.

Changes

File(s) Change Summary
app/client/src/.../WDSCustomWidget/component/useCustomWidgetHeight.ts Inverts canvas element check, introduces updateHeight function, replaces return in switch with break, and adds a ResizeObserver for height updates.
app/client/src/.../WDSCustomWidget/helpers/index.ts Simplifies getFitPageChatHeight by removing the calc function; returns plain pixel height when isEmbed is true.
app/client/src/.../CustomWidgetBuilder/constants.ts Updates the CUSTOM_WIDGET_AI_BOT_URL constant to a new development environment URL; the previous URL is now commented out.

Sequence Diagram(s)

sequenceDiagram
    participant C as Component
    participant U as useCustomWidgetHeight
    participant RO as ResizeObserver
    participant canvas as Canvas Element

    C->>U: Mount component
    U->>canvas: Check for existence
    alt Canvas not found
        U-->>C: Exit function early
    else Canvas found
        U->>U: Define and call updateHeight (set initial height)
        U->>RO: Initialize ResizeObserver on canvas
        RO->>U: On resize event, trigger updateHeight
        U->>canvas: Update height based on size
    end
    C->>RO: Component unmount
    RO->>RO: Disconnect observer (cleanup)
Loading

Suggested labels

Bug, skip-changelog, ok-to-test

Suggested reviewers

  • hetunandu
  • ankitakinger

Poem

In the realm of code so bright,
A canvas check shines its light.
Resize observers dance with glee,
Setting heights perfectly, you see.
New URLs and cleaner lines—
A code art tune in joyful rhymes!
🚀✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f5b5df8 and 9391fcd.

📒 Files selected for processing (3)
  • app/client/src/modules/ui-builder/ui/wds/WDSCustomWidget/component/useCustomWidgetHeight.ts (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSCustomWidget/helpers/index.ts (1 hunks)
  • app/client/src/pages/Editor/CustomWidgetBuilder/constants.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
🔇 Additional comments (5)
app/client/src/modules/ui-builder/ui/wds/WDSCustomWidget/helpers/index.ts (1)

12-12: Simplified height calculation logic

Removed unnecessary calc() wrapper when in embed mode, making the code more straightforward.

app/client/src/pages/Editor/CustomWidgetBuilder/constants.ts (1)

72-75: Updated AI bot URL to development environment

Switched from internal URL to development URL while preserving the same parameter structure. Good practice to keep the previous URL commented for reference.

app/client/src/modules/ui-builder/ui/wds/WDSCustomWidget/component/useCustomWidgetHeight.ts (3)

17-17: Added early return for missing canvas element

Good defensive programming - preventing further execution when the canvas element isn't available.


19-35: Encapsulated height calculation logic in updateHeight function

Refactored the height calculation into a separate function for better organization and reusability. The switch statement now uses break statements instead of returns, which improves readability.


39-45: Added ResizeObserver for dynamic height updates

Great enhancement! Using ResizeObserver to dynamically update the height when the canvas resizes improves the widget's responsiveness. The observer is properly cleaned up on unmount to prevent memory leaks.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Feb 25, 2025
Copy link

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

Copy link

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

@hetunandu
Copy link
Member

/build-deploy-preview

Copy link

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

Copy link

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

@github-actions github-actions bot added Bug Something isn't working IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Medium Issues that frustrate users due to poor UX Production and removed Bug Something isn't working labels Feb 25, 2025
@hetunandu hetunandu added Bug Something isn't working ok-to-test Required label for CI labels Feb 25, 2025
@github-actions github-actions bot removed the Bug Something isn't working label Feb 25, 2025
@jsartisan jsartisan merged commit ac2be25 into release Feb 25, 2025
55 of 59 checks passed
@jsartisan jsartisan deleted the chore/fix-custom-widget-height-issue branch February 25, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Medium Issues that frustrate users due to poor UX ok-to-test Required label for CI Production skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Custom widget AI assistant doesn't load when switching tabs
2 participants