-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(color-field): color handle positioning within scrollable containers #5322
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: aaf75b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 84 packages
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 |
Branch previewReview the following VRT differencesWhen 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 |
Tachometer resultsCurrently, no packages are changed by this PR... |
position: relative; | ||
} | ||
|
||
sp-color-handle { |
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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 = [ |
There was a problem hiding this comment.
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?
[DO NOT MERGE] Waiting for the new golden Image hash to be generated! |
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
Did it pass in Desktop?
Did it pass in Mobile?
Did it pass in iPad?
Screenshots (if appropriate)
Before

After

Types of changes
Checklist
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
.