Skip to content

Commit

Permalink
🐛 work around the 2 types for manager.selection
Browse files Browse the repository at this point in the history
- grapher provides a SelectionArray but a bunch of ad-hoc managers define `selection` as a string[] of entity names
  • Loading branch information
samizdatco committed Sep 6, 2023
1 parent 2e87408 commit a919235
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/@ourworldindata/grapher/src/controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,18 @@ export class SettingsMenu extends React.Component<{
}

@computed get showZoomToggle(): boolean {
return (
!this.manager.hideZoomToggle && this.manager.type === ScatterPlot
// TODO: make this work around the definition that `selection`
// might just be an array of strings…
// && this.manager.selection.hasSelection
)
// TODO:
// grapher passes a SelectionArray instance but programmatically defined
// managers treat `selection` as a string[] of entity names. do we need both?
const { selection, type, hideZoomToggle } = this.manager,
entities =
selection instanceof SelectionArray
? selection.selectedEntityNames
: Array.isArray(selection)
? selection
: []

return !hideZoomToggle && type === ScatterPlot && entities.length > 0
}

@computed get showNoDataAreaToggle(): boolean {
Expand Down

0 comments on commit a919235

Please sign in to comment.