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: use translate to center the resize handle #35665

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Aug 13, 2024

Fixes #35232

Because of how sub-pixels are handled in browsers, the resize handle was previously looking more inclined towards right. By using translate instead adjusting the width in left property, the issue seems to be resolved.

Before:
CleanShot 2024-08-13 at 17 08 47@2x

After:
CleanShot 2024-08-13 at 17 08 00@2x

Summary by CodeRabbit

  • New Features

    • Enhanced positioning logic for the space distribution handle, simplifying the alignment process and potentially improving rendering behavior.
  • Documentation

    • Added comments to clarify the rationale behind adjustments in the positioning logic and highlight the benefits of using translateX for centering.
  • Bug Fixes

    • Resolved potential pixel snapping issues related to the handle's positioning.

Warning

Tests have not run on the HEAD 801900e yet


Tue, 13 Aug 2024 12:05:21 UTC

Copy link
Contributor

coderabbitai bot commented Aug 13, 2024

Walkthrough

The recent changes to the SpaceDistributionHandle focus on optimizing the positioning logic of the space distribution handle to eliminate pixel snapping issues. By simplifying the calculation for the handle's left position and utilizing CSS for centering, the updates enhance clarity and rendering behavior. Additionally, adjustments in related utility functions include clarification comments to aid future developers in understanding the rationale behind certain calculations.

Changes

Files Change Summary
app/client/src/layoutSystems/anvil/sectionSpaceDistributor/SpaceDistributionHandle.tsx Simplified left position calculations for the handle, removing width adjustments and enhancing clarity with CSS centering. Added comments for better understanding.
app/client/src/layoutSystems/anvil/sectionSpaceDistributor/utils/spaceDistributionEditorUtils.ts Added comment in getAnvilZoneBoundaryOffset function regarding the addition of a constant value 2, clarifying the need for further investigation.

Assessment against linked issues

Objective Addressed Explanation
Fix handle positioning to avoid appearing on zone boundaries (#[35232])

In code we dance, with logic refined,
Handles now glide, perfectly aligned.
No more boundaries to cause us dismay,
In pixels we trust as we style and play.
A sprinkle of comments, to guide the way,
In our coding journey, let clarity stay! 🌟


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 Configuration 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 Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Production Regressed Scenarios that were working before but have now regressed Stale skip-changelog Adding this label to a PR prevents it from being listed in the changelog and removed Bug Something isn't working labels Aug 13, 2024
@github-actions github-actions bot added the Bug Something isn't working label Aug 13, 2024
@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot removed the Bug Something isn't working label Aug 13, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/10368860102.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 35665.
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 232b10c and eb8e730.

Files selected for processing (2)
  • app/client/src/layoutSystems/anvil/sectionSpaceDistributor/SpaceDistributionHandle.tsx (3 hunks)
  • app/client/src/layoutSystems/anvil/sectionSpaceDistributor/utils/spaceDistributionEditorUtils.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/layoutSystems/anvil/sectionSpaceDistributor/utils/spaceDistributionEditorUtils.ts
Additional comments not posted (3)
app/client/src/layoutSystems/anvil/sectionSpaceDistributor/SpaceDistributionHandle.tsx (3)

32-34: Great use of transform: translateX(-50%) for centering!

This approach is excellent for handling sub-pixel rendering issues and simplifies the centering logic, making it more robust.


71-71: The position calculation is clear and concise!

The updated logic for calculating the handle's left position is straightforward and effectively addresses the pixel snapping issue.


97-97: The left position calculation is well-aligned with the objectives!

Subtracting half the zone gap ensures the handle is centered between zones, consistent with the overall improvements in this PR.

KelvinOm
KelvinOm previously approved these changes Aug 13, 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.

Could you please make a video about what changed?

@@ -56,6 +56,7 @@ const getElementsBoundingBoxValue = (ele: HTMLElement) => {
export const getAnvilZoneBoundaryOffset = (zoneId: string) => {
const zoneDom = document.getElementById(getAnvilWidgetDOMId(zoneId));
if (zoneDom) {
// (TODO: Anvil): Why is 2 added here?
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is useless. Who knows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea but wanted to keep a track on this.

Copy link

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

@github-actions github-actions bot added the Bug Something isn't working label Aug 13, 2024
@jsartisan
Copy link
Contributor Author

@KelvinOm added before/after images.

@github-actions github-actions bot removed the Bug Something isn't working label Aug 13, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Stale labels Aug 13, 2024
@KelvinOm KelvinOm merged commit b6a785b into release Aug 14, 2024
17 checks passed
@KelvinOm KelvinOm deleted the chore/fix-zone-resize-position branch August 14, 2024 07:39
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 Production Regressed Scenarios that were working before but have now regressed 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]: Space distribution handle appears on the zone boundary
2 participants