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

perf: Anvil widget name component rendering #33672

Merged
merged 7 commits into from
May 23, 2024

Conversation

riodeuno
Copy link
Contributor

@riodeuno riodeuno commented May 23, 2024

Description

  • Fixes some of the performance issues in the widget name component for Anvil. Particularly, the following
    • All widget name components for all widgets used to be added to the DOM tree, even if they're not visible
    • All widget name components had the floating-ui listeners added to them at all times, leading to a sharp rise in the number of JS listeners and increasing RAM usage.
    • Widget name component positions used to recompute sporadically, leading to perceived jitter when users scrolled too quickly.

The above issues have been fixed by the following changes

  • Widget name component gets added to the DOM only when nameComponentState !== "none"
  • Widget name component only has listeners added by floating-ui when the name component needs to be visible
  • Floating-ui is configured to recompute in all requestAnimationFrame cycles

Fixes #33386
Fixes #33330

Automation

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

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9205700153
Commit: db2487d
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/BugTests/GitBugs_Spec.ts
To know the list of identified flaky tests - Refer here

Communication

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

  • Yes
  • No

- Add a ghost component that prevents the widget underneath the widget
  name component from being focused
- Select widget when dragging a focused widget from the widget name
  component
- Adjust offsets and sizes of the ghost component and the widget name
  button
- Remove onMouseLeave events from widgets and add an onMouseLeave event
  to the Canvas.
## Description
- If the parent is already selected, disable parent selection
- Introduce the selector to check if parent is selected.


Fixes #33648 

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
- Ask floating UI to recompute more frequently to make sure the widget
  and widget name component don't stray away when users interact quickly

- Add a widget name component to the DOM tree only if they're supposed
  to be visible
@riodeuno riodeuno self-assigned this May 23, 2024
@riodeuno riodeuno requested a review from a team as a code owner May 23, 2024 02:45
Copy link
Contributor

coderabbitai bot commented May 23, 2024

Walkthrough

Walkthrough

The changes improve the positioning, visibility, and behavior of the AnvilWidgetName component within the editor. These adjustments aim to address issues related to transient widget states during scrolling and enhance the overall user experience.

Changes

File Path Change Summary
app/client/src/layoutSystems/anvil/editor/AnvilWidgetName/utils.ts Modified handleWidgetUpdate for better positioning calculations, visibility handling, and z-index management. Adjusted getWidgetNameComponentStyleProps for parent selection toggling.

Assessment against linked issues

Objective Addressed Explanation
Selected and hover states of a widget are easily visible while scrolling through the canvas (#33386)

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8a9ac19 and db2487d.
Files selected for processing (1)
  • app/client/src/layoutSystems/anvil/editor/AnvilWidgetName/utils.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/layoutSystems/anvil/editor/AnvilWidgetName/utils.ts

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

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.

@github-actions github-actions bot added Anvil Pod Issue related to Anvil project Anvil team issues related to the new layout system anvil High This issue blocks a user from building or impacts a lot of users Task A simple Todo labels May 23, 2024
@riodeuno riodeuno changed the base branch from release to feat/drag-widget-name-component-on-hover May 23, 2024 02:45
@riodeuno riodeuno added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 23, 2024
@riodeuno riodeuno linked an issue May 23, 2024 that may be closed by this pull request
1 task
@riodeuno
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

Base automatically changed from feat/drag-widget-name-component-on-hover to release May 23, 2024 09:32
…o perf/anvil-widget-name-component-rendering
@riodeuno
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the Bug Something isn't working label May 23, 2024
Copy link
Collaborator

@KelvinOm KelvinOm left a comment

Choose a reason for hiding this comment

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

LGTM. Just one question. Why are we changing the id?

2024-05-23.12.32.56.mov

@riodeuno riodeuno added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 23, 2024
Copy link

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

@riodeuno
Copy link
Contributor Author

@KelvinOm Nice observation. Not sure what is happening. Floating-ui is creating these and I believe this is because floating-ui is getting different references so, creating different DOM nodes.

Copy link

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

@riodeuno riodeuno merged commit e0df8f7 into release May 23, 2024
80 of 82 checks passed
@riodeuno riodeuno deleted the perf/anvil-widget-name-component-rendering branch May 23, 2024 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil Pod Issue related to Anvil project Anvil team issues related to the new layout system anvil Bug Something isn't working High This issue blocks a user from building or impacts a lot of users ok-to-test Required label for CI Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect transient widget name state [Bug]: Performance degradation post widget selection changes
3 participants