You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ui-color-picker): fix popover scrolling when content exceeds viewport
This fix ensures the ColorPicker popover displays properly and is scrollable
when its content (ColorMixer, ColorPreset, ColorContrast) would exceed the
available viewport space.
Key improvements:
- Calculate max height dynamically based on available viewport space
- Support both upward and downward popover placement
- Use double requestAnimationFrame to ensure accurate measurements after
Emotion finishes injecting CSS-in-JS styles and child components complete
their mount lifecycle
- Add opacity transition to prevent visual jump when popover opens
- Reset calculated height state on close to fix alternating open/close behavior
- Add visual regression tests
The double rAF approach was necessary because a single requestAnimationFrame
was insufficient for the timing requirements of Emotion's dynamic style
injection. The solution works reliably regardless of React StrictMode setting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: packages/ui-color-picker/src/ColorPicker/README.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -351,3 +351,60 @@ type: example
351
351
</div>
352
352
353
353
```
354
+
355
+
### Scrollable Popover Content
356
+
357
+
When the ColorPicker popover contains tall content (e.g., ColorMixer + ColorPreset + ColorContrast), the component automatically calculates the available viewport space and makes the popover scrollable.
358
+
359
+
The `popoverMaxHeight` prop can be used to set a custom maximum height for the popover content. By default, it's set to `'100vh'`, but the component dynamically adjusts this based on the available space to ensure the popover fits within the viewport and remains scrollable.
360
+
361
+
```js
362
+
---
363
+
type: example
364
+
---
365
+
<ColorPicker
366
+
label="Color"
367
+
placeholderText="Enter HEX"
368
+
popoverButtonScreenReaderLabel="Open color mixer popover"
369
+
popoverMaxHeight="500px"
370
+
colorMixerSettings={{
371
+
popoverAddButtonLabel:"Add",
372
+
popoverCloseButtonLabel:"Cancel",
373
+
colorMixer: {
374
+
withAlpha:true,
375
+
rgbRedInputScreenReaderLabel:'Input field for red',
376
+
rgbGreenInputScreenReaderLabel:'Input field for green',
377
+
rgbBlueInputScreenReaderLabel:'Input field for blue',
378
+
rgbAlphaInputScreenReaderLabel:'Input field for alpha',
379
+
colorSliderNavigationExplanationScreenReaderLabel:`You are on a color slider. To navigate the slider left or right, use the 'A' and 'D' buttons respectively`,
380
+
alphaSliderNavigationExplanationScreenReaderLabel:`You are on an alpha slider. To navigate the slider left or right, use the 'A' and 'D' buttons respectively`,
381
+
colorPaletteNavigationExplanationScreenReaderLabel:`You are on a color palette. To navigate on the palette up, left, down or right, use the 'W', 'A', 'S' and 'D' buttons respectively`
popoverButtonScreenReaderLabel="View and choose color"
201
+
popoverScreenReaderLabel="Color picker popup"
202
+
colorMixerSettings={{
203
+
popoverAddButtonLabel: 'Apply',
204
+
popoverCloseButtonLabel: 'Cancel',
205
+
colorMixer: {
206
+
withAlpha: true,
207
+
rgbRedInputScreenReaderLabel: 'Input field for red',
208
+
rgbGreenInputScreenReaderLabel: 'Input field for green',
209
+
rgbBlueInputScreenReaderLabel: 'Input field for blue',
210
+
rgbAlphaInputScreenReaderLabel: 'Input field for alpha',
211
+
colorSliderNavigationExplanationScreenReaderLabel: `You are on a color slider. To navigate the slider left or right, use the 'A' and 'D' buttons respectively`,
212
+
alphaSliderNavigationExplanationScreenReaderLabel: `You are on an alpha slider. To navigate the slider left or right, use the 'A' and 'D' buttons respectively`,
213
+
colorPaletteNavigationExplanationScreenReaderLabel: `You are on a color palette. To navigate on the palette up, left, down or right, use the 'W', 'A', 'S' and 'D' buttons respectively`
0 commit comments