Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ (explorer) make selected entity travel on top #3393

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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