Skip to content

Commit 72150d8

Browse files
balzssclaude
andcommitted
fix(ui-color-picker): fix mixer button alignment and visual jump
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 <[email protected]>
1 parent 9e06ba2 commit 72150d8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/ui-color-picker/src/ColorPicker/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
129129

130130
handleInputContainerRef = (el: Element | null) => {
131131
this.inputContainerRef = el
132-
this.setLabelHeight()
132+
133+
if (el) {
134+
// Defer measurement until after layout is complete and CSS-in-JS styles are applied
135+
requestAnimationFrame(() => {
136+
this.setLabelHeight()
137+
})
138+
}
133139
}
134140

135141
popoverContentRef: HTMLDivElement | null = null
@@ -714,7 +720,10 @@ class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
714720
{!this.isSimple && (
715721
<div
716722
css={this.props.styles?.colorMixerButtonContainer}
717-
style={{ paddingTop: this.state.labelHeight }}
723+
style={{
724+
alignSelf: this.state.labelHeight > 0 ? 'flex-start' : 'flex-end',
725+
paddingTop: this.state.labelHeight
726+
}}
718727
>
719728
<div css={this.props.styles?.colorMixerButtonWrapper}>
720729
{this.renderPopover()}

packages/ui-color-picker/src/ColorPicker/styles.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ const generateStyle = (
122122
},
123123
colorMixerButtonContainer: {
124124
label: 'colorPicker__colorMixerButtonContainer',
125-
alignSelf: 'flex-start',
126125
marginInlineStart: componentTheme.colorMixerButtonContainerLeftMargin
127126
},
128127
popoverContentContainer: {

0 commit comments

Comments
 (0)