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

fix: widget overflow behaviour in anvil #33961

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented Jun 4, 2024

Description

Fixed overflow operation for widgets in zones.

Fixes
#32922
#33537

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9386697113
Commit: e0f8f24
Cypress dashboard url: Click here!

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced dynamic font size customization using CSS custom properties.
  • Improvements

    • Adjusted layout behavior for AnvilFlexComponent to use fit-content for better content fitting.
    • Enhanced styling for elements with elevation property, including font size and spacing adjustments.
    • Switched to isEditOnlyModeSelector for more accurate layout wrapping behavior in SectionRow.
  • Removals

    • Removed renderMode property from BaseLayoutComponent, FlexLayoutProps, and related components for streamlined functionality.
    • Simplified imports and prop handling in AlignedWidgetRowComp.

Copy link
Contributor

coderabbitai bot commented Jun 4, 2024

Walkthrough

The recent updates address layout and styling issues in the Anvil design system. Key changes include adding a new CSS custom property for typography, modifying the width property in AnvilFlexComponent, adjusting CSS selectors for elevation, and removing the renderMode property from various components. These changes aim to improve layout behavior and resolve specific bugs, such as the button widget position glitch.

Changes

Files Change Summary
.../useCssTokens.tsx Added a new CSS custom property --${currentKey}-font-size in the getTypographyCss function.
.../AnvilFlexComponent.tsx Changed width property from "max-content" to "fit-content".
.../styles.module.css Modified elevation="2" and [data-elevation="false"][elevation="2"] selectors to adjust min-block-size and add font-size.
.../BaseLayoutComponent.tsx Removed renderMode property from the constructor.
.../FlexLayout.tsx Removed renderMode property from FlexLayoutProps interface.
.../alignedWidgetRow/AlignedWidgetRowComp.tsx Removed MOBILE_BREAKPOINT import, adjusted props destructuring to remove renderMode and add width and minWidth.
.../section/SectionRow.tsx Replaced previewModeSelector with isEditOnlyModeSelector for determining layout wrapping behavior.

Assessment against linked issues

Objective Addressed Explanation
Fix button widget position glitch when it reaches the end of the row length (#32922)

Poem

In the land of code, where widgets roam free,
A button found its place, glitching with glee.
With tweaks and turns, the layout refined,
Now it fits snugly, perfectly aligned.
Cheers to the devs, with their magical touch,
For fixing the bugs we love so much!
🐇✨


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.
    • @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 as 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 configuration to show the current CodeRabbit configuration for the repository.
  • @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.

@KelvinOm KelvinOm requested review from marks0351 and ramsaptami June 4, 2024 10:12
@KelvinOm KelvinOm added skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs skip-testPlan ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 4, 2024
@github-actions github-actions bot added Bug Something isn't working and removed skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Jun 4, 2024
@KelvinOm KelvinOm changed the title fix: button widget overflows fix: widget overflows Jun 4, 2024
@KelvinOm KelvinOm force-pushed the fix/button-widget-overflows branch from 32d8b50 to 837de75 Compare June 5, 2024 13:35
@KelvinOm KelvinOm force-pushed the fix/button-widget-overflows branch from 837de75 to e0f8f24 Compare June 5, 2024 15:10
@KelvinOm KelvinOm added the ok-to-test Required label for CI label Jun 5, 2024
@KelvinOm
Copy link
Collaborator Author

KelvinOm commented Jun 5, 2024

/build-deploy-preview skip-tests=true

@KelvinOm KelvinOm marked this pull request as ready for review June 5, 2024 15:12
Copy link

github-actions bot commented Jun 5, 2024

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

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

Outside diff range and nitpick comments (4)
app/client/src/layoutSystems/anvil/layoutComponents/components/FlexLayout.tsx (1)

Line range hint 74-74: Correct the dependencies in useMemo hooks.

- }, [widgetConfigProps, widgetSize, flexGrow]);
+ }, [widgetConfigProps, widgetSize, flexGrow, className]);

Ensure all necessary dependencies are included for correct re-computation.

Also applies to: 117-117

app/client/src/layoutSystems/anvil/layoutComponents/components/alignedWidgetRow/AlignedWidgetRowComp.tsx (1)

Line range hint 39-39: Ensure all dependencies are specified in useMemo.

- }, []);
+ }, [canvasId, props.className, props.parentDropTarget]);

Including all relevant dependencies will ensure that the component re-renders correctly when these properties change.

app/client/src/layoutSystems/anvil/layoutComponents/BaseLayoutComponent.tsx (2)

Line range hint 72-72: Avoid using this in a static context.

The use of this in static methods can lead to confusion as it does not refer to an instance of the class. Consider using the class name BaseLayoutComponent instead to access static properties or methods.

- return this.rendersWidgets ? extractWidgetIdsFromLayoutProps(props) : [];
+ return BaseLayoutComponent.rendersWidgets ? extractWidgetIdsFromLayoutProps(props) : [];

Line range hint 77-77: Consider using optional chaining for better safety and readability.

Using optional chaining can help avoid runtime errors if props.allowedWidgetTypes is undefined. Here's how you can refactor the code:

- if (props.allowedWidgetTypes && props.allowedWidgetTypes.length) {
+ if (props.allowedWidgetTypes?.length) {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8abc516 and e0f8f24.

Files selected for processing (7)
  • app/client/packages/design-system/theming/src/hooks/src/useCssTokens.tsx (1 hunks)
  • app/client/src/layoutSystems/anvil/common/AnvilFlexComponent.tsx (1 hunks)
  • app/client/src/layoutSystems/anvil/common/styles.module.css (1 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/BaseLayoutComponent.tsx (1 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/FlexLayout.tsx (2 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/alignedWidgetRow/AlignedWidgetRowComp.tsx (3 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/section/SectionRow.tsx (1 hunks)
Additional context used
Biome
app/client/src/layoutSystems/anvil/layoutComponents/components/FlexLayout.tsx

[error] 74-74: This hook does not specify all of its dependencies: className (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 74-74: This hook specifies more dependencies than necessary: isDropTarget (lint/correctness/useExhaustiveDependencies)

This dependency can be removed from the list.


[error] 117-117: This hook specifies more dependencies than necessary: isDropTarget (lint/correctness/useExhaustiveDependencies)

This dependency can be removed from the list.


[error] 126-126: This hook does not specify all of its dependencies: className (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

app/client/src/layoutSystems/anvil/layoutComponents/components/alignedWidgetRow/AlignedWidgetRowComp.tsx

[error] 39-39: This hook does not specify all of its dependencies: canvasId (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

Either include it or remove the dependency array


[error] 39-39: This hook does not specify all of its dependencies: props.className (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

Either include it or remove the dependency array


[error] 39-39: This hook does not specify all of its dependencies: props.parentDropTarget (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

Either include it or remove the dependency array

app/client/src/layoutSystems/anvil/layoutComponents/BaseLayoutComponent.tsx

[error] 72-72: Using this in a static context can be confusing. (lint/complexity/noThisInStatic)

this refers to the class.
Unsafe fix: Use the class name instead.


[error] 77-77: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (5)
app/client/src/layoutSystems/anvil/layoutComponents/components/section/SectionRow.tsx (2)

3-3: Updated import to use isEditOnlyModeSelector instead of previewModeSelector.


7-9: Switched conditional logic for wrap property based on isEditOnlyMode.

This change aligns with the PR's objective to fix widget overflow by ensuring proper containment within designated areas.

app/client/packages/design-system/theming/src/hooks/src/useCssTokens.tsx (1)

39-39: Introduced new CSS custom properties for typography settings.

This enhancement allows dynamic adjustment of typography based on theme settings, improving flexibility and maintainability.

app/client/src/layoutSystems/anvil/common/styles.module.css (1)

30-39: Updated CSS rules for elevation="2" to include dynamic font size and block size calculations.

These changes enhance the visual consistency and responsiveness of UI components at different elevation levels.

Also applies to: 42-45

app/client/src/layoutSystems/anvil/common/AnvilFlexComponent.tsx (1)

82-82: Changed width property from "max-content" to "fit-content".

This adjustment likely aims to improve the content fitting behavior within flex containers, aligning with the PR's objectives to fix layout issues.

Copy link

github-actions bot commented Jun 5, 2024

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

@marks0351 marks0351 changed the title fix: widget overflows fix: widget overflow behaviour in anvil Jun 6, 2024
@KelvinOm KelvinOm merged commit 05aa9cc into release Jun 6, 2024
52 of 53 checks passed
@KelvinOm KelvinOm deleted the fix/button-widget-overflows branch June 6, 2024 10:49
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI skip-docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants