Skip to content

Commit

Permalink
✨ (explorer) make selected entity travel on top (#3393)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann authored Apr 16, 2024
1 parent c7e732b commit c10330d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ $zindex-dropdown: 100;
z-index: 1;
}

&.most-recently-selected {
z-index: 2;
}

&.focused {
background-color: $gray-10;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class EntityPicker extends React.Component<{

@observable private blockOptionHover = false

@observable private mostRecentlySelectedEntityName: string | null = null

@observable
private scrollContainerRef: React.RefObject<HTMLDivElement> =
React.createRef()
Expand All @@ -92,12 +94,15 @@ export class EntityPicker extends React.Component<{
checked?: boolean
): void {
this.manager.selection.toggleSelection(name)

// Clear search input
this.searchInput = ""
this.manager.analytics?.logEntityPickerEvent(
checked ? "select" : "deselect",
name
)

this.mostRecentlySelectedEntityName = name
}

@computed private get manager(): EntityPickerManager {
Expand Down Expand Up @@ -623,6 +628,13 @@ export class EntityPicker extends React.Component<{
? this.focusRef
: undefined
}
className={
this
.mostRecentlySelectedEntityName ===
option.entityName
? "most-recently-selected"
: undefined
}
/>
))}
</Flipper>
Expand Down Expand Up @@ -658,6 +670,7 @@ interface PickerOptionProps {
isSelected?: boolean
barScale?: ScaleLinear<number, number>
hasDataForActiveMetric: boolean
className?: string
}

class PickerOption extends React.Component<PickerOptionProps> {
Expand All @@ -679,6 +692,7 @@ class PickerOption extends React.Component<PickerOptionProps> {
isFocused,
hasDataForActiveMetric,
highlight,
className,
} = this.props
const { entityName, plotValue, formattedValue } = optionWithMetricValue
const metricValue = formattedValue === entityName ? "" : formattedValue // If the user has this entity selected, don't show the name twice.
Expand All @@ -688,6 +702,7 @@ class PickerOption extends React.Component<PickerOptionProps> {
<label
className={classnames(
"EntityPickerOption",
className,
{
selected: isSelected,
focused: isFocused,
Expand Down

0 comments on commit c10330d

Please sign in to comment.