Skip to content

fix(ui-color-picker): fix popover scrolling + docs routing#2237

Merged
balzss merged 3 commits intomasterfrom
fix/color-picker-scrolling
Nov 19, 2025
Merged

fix(ui-color-picker): fix popover scrolling + docs routing#2237
balzss merged 3 commits intomasterfrom
fix/color-picker-scrolling

Conversation

@balzss
Copy link
Contributor

@balzss balzss commented Nov 11, 2025

Summary

Fixed multiple ColorPicker issues related to popover scrolling and mixer button alignment.

Issue 1: Popover Scrolling

Fixed ColorPicker popover scrolling when content exceeds viewport height. The popover now dynamically calculates available space based on placement (above/below trigger) and becomes scrollable when needed. A smooth fade-in transition prevents visual jump on opening.

Issue 2: Mixer Button Alignment

Fixed mixer button alignment and visual jump issues:

  • Alignment calculation: Was returning 0 due to timing - now uses requestAnimationFrame to defer measurement until CSS-in-JS styles are applied
  • Visual jump: Button now starts bottom-aligned and dynamically switches to top-aligned after calculation completes, minimizing the visible jump

Key Changes

  • Dynamic max-height calculation for both upward/downward popover placement
  • Double requestAnimationFrame for popover to wait for Emotion CSS-in-JS injection and child component mounting
  • Single requestAnimationFrame for mixer button alignment to wait for layout completion
  • Opacity transition with state flag to prevent visual jump in popover
  • Dynamic alignSelf switching for mixer button to minimize visual jump
  • State reset on close to fix alternating open/close behavior
  • Added visual regression tests
  • Fixed docs dev server client-side routing (webpack historyApiFallback)

Test Plan

  • Open ColorPicker with tall content near bottom/top of viewport
  • Verify popover is scrollable and opens smoothly without visual jump
  • Test multiple open/close cycles
  • Verify mixer button aligns correctly with input field
  • Verify minimal visual jump when mixer button appears
  • Verify docs dev server routing works on refresh

Refs INSTUI-4849

🤖 Generated with Claude Code

@balzss balzss requested review from HerrTopi and ToMESSKa November 11, 2025 13:34
@balzss balzss self-assigned this Nov 11, 2025
@github-actions
Copy link

github-actions bot commented Nov 11, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-11-19 09:56 UTC

@balzss balzss force-pushed the fix/color-picker-scrolling branch 2 times, most recently from 9cd5c36 to 31f7770 Compare November 12, 2025 14:07
Copy link
Contributor

@ToMESSKa ToMESSKa left a comment

Choose a reason for hiding this comment

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

@balzss When I first open the ColorPicker popover, the top cannot be seen. If scroll down and up again, the popover shirks and the scrollbar appears.

balzss and others added 2 commits November 13, 2025 14:47
Added historyApiFallback to webpack dev server config to properly handle
client-side routing. Without this, refreshing the page on non-root routes
would return 404 errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…port

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 <noreply@anthropic.com>
@balzss balzss force-pushed the fix/color-picker-scrolling branch from 31f7770 to 9e06ba2 Compare November 13, 2025 13:59
@balzss balzss requested a review from ToMESSKa November 13, 2025 14:15
Copy link
Contributor

@ToMESSKa ToMESSKa left a comment

Choose a reason for hiding this comment

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

If I open the ColorPicker, select a color and click 'Add' and then open the ColorPicker again, the viewport size is not respected and scrolling isn't avaliable.

@balzss balzss requested review from ToMESSKa and matyasf November 14, 2025 10:36
Copy link
Contributor

@HerrTopi HerrTopi left a comment

Choose a reason for hiding this comment

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

Lgtm. At least good enough. If you select a color and close the popover, it wont scroll if opened again. If closed and open again, it works as expected. Good for now

@balzss balzss force-pushed the fix/color-picker-scrolling branch from 72150d8 to 73c4c6b Compare November 18, 2025 11:46
@HerrTopi HerrTopi self-requested a review November 18, 2025 11:50
@balzss balzss force-pushed the fix/color-picker-scrolling branch from 73c4c6b to 64c75dc Compare November 18, 2025 11:56
Copy link
Collaborator

@matyasf matyasf left a comment

Choose a reason for hiding this comment

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

There is a horizontal scrollbar in FF, otherwise it looks good

Image

Comment on lines +148 to +154
cy.injectAxe()
// TODO: Fix ARIA violations before enabling a11y check
// - aria-allowed-attr (critical): 1 node
// - aria-prohibited-attr (serious): 3 nodes
// ColorMixer has aria-disabled on plain div without proper role
// cy.checkA11y('.axe-test', axeOptions, terminalLog)
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

These issues existed before this PR, right? (I dont see them when I run in the example page with a ColorPicker open)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think they existed but we didn't have colorpicker examples before this pr

Fixed two issues with the ColorPicker mixer button:
1. Alignment calculation returning 0 due to timing - measurement now happens
   after CSS-in-JS styles are applied using requestAnimationFrame
2. Visual jump on load - button now starts bottom-aligned and switches to
   top-aligned after calculation completes, minimizing the jump

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@balzss balzss force-pushed the fix/color-picker-scrolling branch from 64c75dc to 32ddef6 Compare November 18, 2025 19:55
@balzss
Copy link
Contributor Author

balzss commented Nov 18, 2025

There is a horizontal scrollbar in FF, otherwise it looks good

@matyasf this should be fixed now

@balzss balzss requested a review from matyasf November 18, 2025 19:56
@balzss balzss merged commit 68c3e60 into master Nov 19, 2025
10 of 11 checks passed
@balzss balzss deleted the fix/color-picker-scrolling branch November 19, 2025 09:56
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.

4 participants

Comments