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(color-field): color handle positioning within scrollable containers #5322

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

blunteshwar
Copy link
Contributor

@blunteshwar blunteshwar commented Apr 3, 2025

Description

Issue
The color handle in sp-color-field components was displaying in incorrect positions when multiple color fields were placed inside a scrollable container. As the container scrolled, the color handles would appear disconnected from their respective color fields, creating a poor user experience.

Root Cause
The issue occurred because absolutely positioned elements (like the sp-color-handle) require a positioned ancestor to establish their coordinate system. Since the position of sp-color-field(host) was by default static so without one, they position themselves relative to the nearest positioned ancestor (often the scrollable container itself), causing positioning inconsistencies during scrolling.

Solution
Added position: relative to the :host selector in color-field.css
This simple change ensures that each color field component establishes its own positioning context, causing the color handle to position itself relative to its parent component sp-color-field rather than a distant ancestor.

Related issue(s)

#5109

Motivation and context

How has this been tested?

  • Test case 1

    1. Go here
    2. Confirm that the color handles maintain correct positioning while scrolling
  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Before
Screenshot 2025-04-03 at 12 09 49 PM

After
Screenshot 2025-04-03 at 12 23 39 PM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

@blunteshwar blunteshwar requested a review from a team as a code owner April 3, 2025 06:52
Copy link

changeset-bot bot commented Apr 3, 2025

🦋 Changeset detected

Latest commit: d97332c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 84 packages
Name Type
@spectrum-web-components/color-field Minor
@spectrum-web-components/bundle Minor
documentation Patch
@spectrum-web-components/eslint-plugin Minor
@spectrum-web-components/accordion Minor
@spectrum-web-components/action-bar Minor
@spectrum-web-components/action-button Minor
@spectrum-web-components/action-group Minor
@spectrum-web-components/action-menu Minor
@spectrum-web-components/alert-banner Minor
@spectrum-web-components/alert-dialog Minor
@spectrum-web-components/asset Minor
@spectrum-web-components/avatar Minor
@spectrum-web-components/badge Minor
@spectrum-web-components/breadcrumbs Minor
@spectrum-web-components/button-group Minor
@spectrum-web-components/button Minor
@spectrum-web-components/card Minor
@spectrum-web-components/checkbox Minor
@spectrum-web-components/clear-button Minor
@spectrum-web-components/close-button Minor
@spectrum-web-components/coachmark Minor
@spectrum-web-components/color-area Minor
@spectrum-web-components/color-handle Minor
@spectrum-web-components/color-loupe Minor
@spectrum-web-components/color-slider Minor
@spectrum-web-components/color-wheel Minor
@spectrum-web-components/combobox Minor
@spectrum-web-components/contextual-help Minor
@spectrum-web-components/dialog Minor
@spectrum-web-components/divider Minor
@spectrum-web-components/dropzone Minor
@spectrum-web-components/field-group Minor
@spectrum-web-components/field-label Minor
@spectrum-web-components/help-text Minor
@spectrum-web-components/icon Minor
@spectrum-web-components/icons-ui Minor
@spectrum-web-components/icons-workflow Minor
@spectrum-web-components/icons Minor
@spectrum-web-components/iconset Minor
@spectrum-web-components/illustrated-message Minor
@spectrum-web-components/infield-button Minor
@spectrum-web-components/link Minor
@spectrum-web-components/menu Minor
@spectrum-web-components/meter Minor
@spectrum-web-components/modal Minor
@spectrum-web-components/number-field Minor
@spectrum-web-components/overlay Minor
@spectrum-web-components/picker-button Minor
@spectrum-web-components/picker Minor
@spectrum-web-components/popover Minor
@spectrum-web-components/progress-bar Minor
@spectrum-web-components/progress-circle Minor
@spectrum-web-components/radio Minor
@spectrum-web-components/search Minor
@spectrum-web-components/sidenav Minor
@spectrum-web-components/slider Minor
@spectrum-web-components/split-view Minor
@spectrum-web-components/status-light Minor
@spectrum-web-components/swatch Minor
@spectrum-web-components/switch Minor
@spectrum-web-components/table Minor
@spectrum-web-components/tabs Minor
@spectrum-web-components/tags Minor
@spectrum-web-components/textfield Minor
@spectrum-web-components/thumbnail Minor
@spectrum-web-components/toast Minor
@spectrum-web-components/tooltip Minor
@spectrum-web-components/top-nav Minor
@spectrum-web-components/tray Minor
@spectrum-web-components/underlay Minor
@spectrum-web-components/custom-vars-viewer Minor
@spectrum-web-components/story-decorator Minor
@spectrum-web-components/vrt-compare Minor
@spectrum-web-components/base Minor
@spectrum-web-components/grid Minor
@spectrum-web-components/opacity-checkerboard Minor
@spectrum-web-components/reactive-controllers Minor
@spectrum-web-components/shared Minor
@spectrum-web-components/styles Minor
@spectrum-web-components/theme Minor
@spectrum-web-components/truncated Minor
example-project-rollup Patch
example-project-webpack Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

github-actions bot commented Apr 3, 2025

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

github-actions bot commented Apr 3, 2025

Tachometer results

Currently, no packages are changed by this PR...

@blunteshwar blunteshwar self-assigned this Apr 3, 2025
@blunteshwar blunteshwar changed the title fix(color-field): add CSS styles to properly define the positioning o… fix(color-field): add CSS styles to color-field Apr 3, 2025
position: relative;
}

sp-color-handle {
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed sp-color-handle already has position: absolute set here: https://github.com/adobe/spectrum-web-components/blob/main/packages/color-handle/src/spectrum-color-handle.css#L48

So we can remove this rule and just leave the position: relative above 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@Rajdeepc Rajdeepc left a comment

Choose a reason for hiding this comment

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

Verified in Mobile and Desktop.LGTM!

position: relative;
}

sp-color-handle {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this not work adding to property to :host?

@@ -61,6 +61,56 @@ viewColor.args = {
viewColor: true,
value: 'rgb(255,255,0)',
};
export const Multiple = (args?: Properties): TemplateResult => {
// Array of predefined colors in different formats
const colors = [
Copy link
Contributor

Choose a reason for hiding this comment

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

can you create a constant file for this?

@Rajdeepc Rajdeepc changed the title fix(color-field): add CSS styles to color-field fix(color-field): color handle positioning within scrollable containers Apr 3, 2025
@blunteshwar blunteshwar changed the title fix(color-field): color handle positioning within scrollable containers [HOLD]fix(color-field): color handle positioning within scrollable containers Apr 3, 2025
@blunteshwar
Copy link
Contributor Author

blunteshwar commented Apr 3, 2025

[DO NOT MERGE] Waiting for the new golden Image hash to be generated!

@blunteshwar blunteshwar changed the title [HOLD]fix(color-field): color handle positioning within scrollable containers fix(color-field): color handle positioning within scrollable containers Apr 3, 2025
@blunteshwar blunteshwar enabled auto-merge (squash) April 3, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants