Skip to content

Commit

Permalink
fix(inspector) Display Grid Template Ellipsis When Hovered (#6539)
Browse files Browse the repository at this point in the history
- Moved the logic in `AxisDimensionControl` that governed the visibility
of the ellipsis to be purely React based instead of using Emotion CSS.
  • Loading branch information
seanparsons authored Oct 16, 2024
1 parent e6dbbf8 commit 2f54a78
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions editor/src/components/inspector/flex-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ import {
import type { Axis } from '../canvas/gap-utils'
import { GridExpressionInput } from '../../uuiui/inputs/grid-expression-input'

const axisDropdownMenuButton = 'axisDropdownMenuButton'

function getLayoutSystem(
layoutSystem: DetectedLayoutSystem | null | undefined,
): 'grid' | 'flex' | null {
Expand Down Expand Up @@ -553,20 +551,20 @@ function AxisDimensionControl({

const gridExpressionInputFocused = useGridExpressionInputFocused()

const [isHovered, setIsHovered] = React.useState(false)
const onMouseEnter = React.useCallback(() => {
setIsHovered(true)
}, [])
const onMouseLeave = React.useCallback(() => {
setIsHovered(false)
}, [])

return (
<div
key={`col-${value}-${index}`}
style={{ display: 'flex', alignItems: 'center', gap: 6 }}
css={{
[`& > .${axisDropdownMenuButton}`]: {
visibility: isOpen ? 'visible' : 'hidden',
},
':hover': {
[`& > .${axisDropdownMenuButton}`]: {
visibility: 'visible',
},
},
}}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
>
<div
style={{
Expand Down Expand Up @@ -600,9 +598,9 @@ function AxisDimensionControl({
onBlur={gridExpressionInputFocused.onBlur}
keywords={gridDimensionDropdownKeywords}
/>
{unless(
gridExpressionInputFocused.focused,
<SquareButton className={axisDropdownMenuButton}>
{when(
(isHovered && !gridExpressionInputFocused.focused) || isOpen,
<SquareButton>
<DropdownMenu align='end' items={items} opener={opener} onOpenChange={onOpenChange} />
</SquareButton>,
)}
Expand Down

0 comments on commit 2f54a78

Please sign in to comment.