Skip to content

Commit

Permalink
Merge pull request #2603 from owid/fix-explorer-entity-picker-sort
Browse files Browse the repository at this point in the history
fix(explorer): prevent metric from being updated when entities are sorted
  • Loading branch information
sophiamersmann authored Sep 2, 2023
2 parents b8e37fa + 09f0740 commit ac62b29
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,10 @@ export class Explorer
setEntityPicker({
metric,
sort,
}: { metric?: string; sort?: SortOrder } = {}) {
}: {
metric: string | undefined
sort?: SortOrder
}) {
this.entityPickerMetric = metric
if (sort) this.entityPickerSort = sort
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ export class EntityPicker extends React.Component<{
className="sort"
onClick={(): void => {
const sortOrder = toggleSort(this.sortOrder)
this.manager.setEntityPicker?.({ sort: sortOrder })
this.manager.setEntityPicker?.({
metric: this.metric,
sort: sortOrder,
})
this.manager.analytics?.logEntityPickerEvent(
"sortOrder",
sortOrder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { SelectionArray } from "../../selection/SelectionArray"
export interface EntityPickerManager {
entityPickerMetric?: ColumnSlug
entityPickerSort?: SortOrder
setEntityPicker?: (options: { metric?: string; sort?: SortOrder }) => void
setEntityPicker?: (options: {
metric: string | undefined
sort?: SortOrder
}) => void
requiredColumnSlugs?: ColumnSlug[] // If this param is provided, and an entity does not have a value for 1+, it will show as unavailable.
entityPickerColumnDefs?: CoreColumnDef[]
entityPickerTable?: OwidTable
Expand Down

0 comments on commit ac62b29

Please sign in to comment.