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

fix bundling issues related to created status #2387

Merged
merged 10 commits into from
Aug 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
onBulkTaskSelection = taskIds => {
const tasks = this.clustersAsTasks().filter(task => {
const taskId = task.id || task.taskId
return taskIds.includes(taskId) &&
const alreadyBundled = task.bundleId && this.props.taskBundle?.bundleId !== task.bundleId

return taskIds.includes(taskId) && !alreadyBundled &&
!(
this.props.task &&
![0, 3, 6].includes(task.taskStatus || task.status) &&
Expand Down
225 changes: 118 additions & 107 deletions src/components/HOCs/WithTaskBundle/WithTaskBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,131 +25,107 @@
resetSelectedTasks: null
}

componentDidMount() {
async componentDidMount() {

Check warning on line 28 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L28

Added line #L28 was not covered by tests
const { task } = this.props
this.setBundlingConditions()
this.setState({ completingTask: null })

if (_isFinite(_get(task, 'bundleId')) && task?.status === 0) {
this.props.deleteTaskBundle(task.bundleId)
} else if (_isFinite(_get(task, 'bundleId'))){
this.setupBundle(task.bundleId)
if (_isFinite(_get(task, 'bundleId'))) {
await this.setupBundle(task.bundleId)
} else {
this.updateBundlingConditions()

Check warning on line 33 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L31-L33

Added lines #L31 - L33 were not covered by tests
}

window.addEventListener('beforeunload', this.handleBeforeUnload)
}

componentDidUpdate(prevProps, prevState) {
const { initialBundle } = this.state
async componentDidUpdate(prevProps, prevState) {

Check warning on line 39 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L39

Added line #L39 was not covered by tests
const { task } = this.props

if (_get(task, 'id') !== _get(prevProps, 'task.id')) {
this.setBundlingConditions()
this.setState({ selectedTasks: [], initialBundle: null, taskBundle: null, loading: false, completingTask: null })
this.setState({

Check warning on line 43 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L43

Added line #L43 was not covered by tests
selectedTasks: [],
initialBundle: null,
taskBundle: null,
loading: false,
completingTask: null
})

if (_isFinite(_get(task, 'bundleId'))) {
this.setupBundle(task.bundleId)
await this.setupBundle(task.bundleId)
} else {
this.updateBundlingConditions()

Check warning on line 54 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L52-L54

Added lines #L52 - L54 were not covered by tests
}

const prevInitialBundle = prevState.initialBundle
const prevTaskBundle = prevState.taskBundle
if ((prevTaskBundle || prevInitialBundle) && prevTaskBundle !== prevInitialBundle && !prevState.completingTask) {
if (initialBundle) {
if (prevInitialBundle) {
// Whenever the user redirects, skips a task, or refreshes and there is a
// new bundle state, the bundle state needs to reset to its initial value.
this.props.resetTaskBundle(prevInitialBundle)
} else {
// Whenever the user redirects, skips a task, or refreshes and there was
// no initial value, the bundle will be destroyed.
this.props.deleteTaskBundle(prevTaskBundle.bundleId)
this.clearActiveTaskBundle()
this.clearActiveTaskBundle(prevTaskBundle.bundleId)

Check warning on line 67 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L67

Added line #L67 was not covered by tests
}
} else if ((prevTaskBundle && prevInitialBundle) && prevTaskBundle !== prevInitialBundle && prevState.completingTask) {
const tasksToUnlock = prevInitialBundle.taskIds.filter(taskId => !prevTaskBundle.taskIds.includes(taskId))
tasksToUnlock.map(taskId => {
this.props.releaseTask(taskId).then(() => {
// wait for lock to be cleared in db and provide some leeway
// time with setTimeout before triggering storage event
setTimeout(() => localStorage.removeItem(`lock-${taskId}`), 1500)
}).catch(() => null)
})
await this.unlockTasks(prevTaskBundle, prevTaskBundle)

Check warning on line 70 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L70

Added line #L70 was not covered by tests
}
}
}

componentWillUnmount() {
this.resetBundle()

this.setState({ selectedTasks: [], initialBundle: null, taskBundle: null, loading: false, completingTask: null })
window.removeEventListener('beforeunload', this.handleBeforeUnload)
}

setBundlingConditions = () => {
updateBundlingConditions = () => {

Check warning on line 80 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L80

Added line #L80 was not covered by tests
const { task, taskReadOnly, workspace, user, name } = this.props
const isCompletionWorkspace = workspace?.name === "taskCompletion" || name === "taskCompletion"
const isReviewWorkspace = workspace?.name === "taskReview" || name === "taskReview"

const isCompletionWorkspace = ["taskCompletion"].includes(workspace?.name || name)
const isReviewWorkspace = ["taskReview"].includes(workspace?.name || name)
const completionStatus = isCompletionWorkspace && ([2].includes(task?.reviewStatus) || [0, 3, 6].includes(task?.status))

const enableMapperEdits = (!task?.completedBy || user.id === task.completedBy) && completionStatus && !isReviewWorkspace
const enableSuperUserEdits = user.isSuperUser && (completionStatus || isReviewWorkspace)

const bundleEditsDisabled = taskReadOnly || (!enableMapperEdits && !enableSuperUserEdits)

this.setState({ bundleEditsDisabled })
}

handleBeforeUnload = () => {
this.resetBundle()

this.setState({ selectedTasks: [], initialBundle: null, taskBundle: null, loading: false, completingTask: null })
}

resetBundle = () => {
const { initialBundle } = this.state
if (!this.state.completingTask) {
resetBundle = async () => {
const { initialBundle, taskBundle, completingTask } = this.state

Check warning on line 97 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L96-L97

Added lines #L96 - L97 were not covered by tests
if (!completingTask) {
this.resetSelectedTasks()
if (
(this.state.taskBundle || this.state.initialBundle) &&
this.state.taskBundle !== this.state.initialBundle &&
!this.state.completingTask
) {
if (taskBundle || initialBundle && taskBundle !== initialBundle) {
if (initialBundle) {
// Whenever the user redirects, skips a task, or refreshes and there is a
// new bundle state, the bundle state needs to reset to its initial value.
this.props.resetTaskBundle(initialBundle)
} else {
// Whenever the user redirects, skips a task, or refreshes and there was
// no initial value, the bundle will be destroyed.
this.props.deleteTaskBundle(this.state.taskBundle.bundleId)
this.clearActiveTaskBundle()
await this.props.resetTaskBundle(initialBundle).catch(console.error)

Check warning on line 102 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L102

Added line #L102 was not covered by tests
} else if (taskBundle) {
await this.clearActiveTaskBundle(taskBundle.bundleId)

Check warning on line 104 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L104

Added line #L104 was not covered by tests
}
}
} else if (
this.state.taskBundle &&
this.state.initialBundle &&
this.state.taskBundle !== this.state.initialBundle &&
this.state.completingTask
) {
const tasksToUnlock = this.state.initialBundle.taskIds.filter(
(taskId) => !this.state.taskBundle.taskIds.includes(taskId)
)
tasksToUnlock.map((taskId) => {
this.props.releaseTask(taskId).then(() => {
// wait for lock to be cleared in db and provide some leeway
// time with setTimeout before triggering storage event
setTimeout(
() => localStorage.removeItem(`lock-${taskId}`),
1500
)
}).catch(() => null)
})
} else if (taskBundle || initialBundle &&taskBundle && initialBundle) {
await this.unlockTasks(initialBundle, taskBundle)

Check warning on line 108 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L108

Added line #L108 was not covered by tests
}
}

setupBundle = bundleId => {
unlockTasks = async (initialBundle, taskBundle) => {
const tasksToUnlock = initialBundle.taskIds.filter(taskId => !taskBundle.taskIds.includes(taskId))
await Promise.all(tasksToUnlock.map(taskId =>
this.props.releaseTask(taskId).then(() => {

Check warning on line 115 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L112-L115

Added lines #L112 - L115 were not covered by tests
// wait for lock to be cleared in db and provide some leeway
// time with setTimeout before triggering storage event
setTimeout(() => localStorage.removeItem(`lock-${taskId}`), 1500)

Check warning on line 118 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L118

Added line #L118 was not covered by tests
}).catch(console.error)
))
}

setupBundle = async (bundleId) => {

Check warning on line 123 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L123

Added line #L123 was not covered by tests
const { task, workspace, history, fetchTaskBundle } = this.props
this.setState({ loading: true })
fetchTaskBundle(bundleId, !this.state.bundleEditsDisabled).then(taskBundle => {
if(taskBundle) {
this.setState({loading: true})
try {
const taskBundle = await fetchTaskBundle(bundleId, !this.state.bundleEditsDisabled)

Check warning on line 127 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L125-L127

Added lines #L125 - L127 were not covered by tests
if (taskBundle) {
if (!task.isBundlePrimary) {
const primaryTask = taskBundle.tasks.find(task => task.isBundlePrimary)
const isMetaReview = history?.location?.pathname?.includes("meta-review")
Expand All @@ -161,34 +137,52 @@
}
}
}
this.setState({ initialBundle: taskBundle, selectedTasks: taskBundle?.taskIds, taskBundle })
})
this.setState({ loading: false })
this.updateBundlingConditions()
this.setState({

Check warning on line 141 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L140-L141

Added lines #L140 - L141 were not covered by tests
initialBundle: taskBundle,
selectedTasks: taskBundle?.taskIds || [],

Check warning on line 143 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L143

Added line #L143 was not covered by tests
taskBundle
})
} catch (error) {
console.error("Error setting up bundle:", error)
this.updateBundlingConditions()

Check warning on line 148 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L147-L148

Added lines #L147 - L148 were not covered by tests
} finally {
this.setState({ loading: false })

Check warning on line 150 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L150

Added line #L150 was not covered by tests
}
}

createTaskBundle = (taskIds, bundleTypeMismatch, name) => {
createTaskBundle = async (taskIds, bundleTypeMismatch, name) => {

Check warning on line 154 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L154

Added line #L154 was not covered by tests
this.setState({loading: true})
this.props.bundleTasks(this.props.taskId, taskIds, bundleTypeMismatch, name).then(taskBundle => {
this.setState({selectedTasks: taskBundle?.taskIds, taskBundle, loading: false})
})
try {
const taskBundle = await this.props.bundleTasks(this.props.taskId, taskIds, bundleTypeMismatch, name)
this.setState({
selectedTasks: taskBundle?.taskIds || [],

Check warning on line 159 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L156-L159

Added lines #L156 - L159 were not covered by tests
taskBundle,
loading: false
})
} catch (error) {
console.error("Error creating task bundle:", error)
this.setState({loading: false})

Check warning on line 165 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L164-L165

Added lines #L164 - L165 were not covered by tests
}
}

resetToInitialTaskBundle = (bundleId) => {
resetToInitialTaskBundle = async (bundleId) => {

Check warning on line 169 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L169

Added line #L169 was not covered by tests
const { initialBundle, taskBundle } = this.state
if(initialBundle && initialBundle !== taskBundle){
if (initialBundle && initialBundle !== taskBundle) {
this.setState({loading: true})
this.props.resetTaskBundle(initialBundle).then(taskBundle => {
this.setState({selectedTasks: taskBundle?.taskIds, taskBundle, loading: false})
})
} else if (
_isFinite(bundleId) &&
_get(this.state, 'taskBundle.bundleId') === bundleId &&
(this.props.task.status === 0)
) {
// The task id we pass to delete will be left locked, so it needs to be
// the current task even if it's not the primary task in the bundle
this.props.deleteTaskBundle(bundleId)
this.clearActiveTaskBundle()
try {
const taskBundle = await this.props.resetTaskBundle(initialBundle)
this.setState({
selectedTasks: taskBundle?.taskIds || [],

Check warning on line 176 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L173-L176

Added lines #L173 - L176 were not covered by tests
taskBundle,
loading: false
})
} catch (error) {
console.error("Error resetting to initial task bundle:", error)
this.setState({loading: false})

Check warning on line 182 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L181-L182

Added lines #L181 - L182 were not covered by tests
}
} else if (_isFinite(bundleId) && _get(this.state, 'taskBundle.bundleId') === bundleId && this.props.task.status === 0) {
await this.clearActiveTaskBundle(bundleId)

Check warning on line 185 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L185

Added line #L185 was not covered by tests
}
}

Expand All @@ -199,24 +193,41 @@
}

removeTaskFromBundle = async (bundleId, taskId) => {
const { initialBundle } = this.state
const { initialBundle, taskBundle } = this.state

Check warning on line 196 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L196

Added line #L196 was not covered by tests
this.setState({loading: true})
if(this.state.taskBundle?.taskIds.length === 2 && !this.state.initialBundle && this.props.task.status === 0) {
this.props.deleteTaskBundle(bundleId)
this.clearActiveTaskBundle()
try {

Check warning on line 198 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L198

Added line #L198 was not covered by tests
if (taskBundle?.taskIds.length === 2 && !initialBundle && this.props.task.status === 0) {
await this.clearActiveTaskBundle(bundleId)
this.setState({loading: false})
return

Check warning on line 202 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L200-L202

Added lines #L200 - L202 were not covered by tests
}

const updatedTaskBundle = await this.props.removeTaskFromBundle(initialBundle?.taskIds, bundleId, taskId)
this.setState({

Check warning on line 206 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L205-L206

Added lines #L205 - L206 were not covered by tests
taskBundle: updatedTaskBundle,
loading: false
})
} catch (error) {
console.error("Error removing task from bundle:", error)

Check warning on line 211 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L211

Added line #L211 was not covered by tests
this.setState({loading: false})
return
}

this.props.removeTaskFromBundle(initialBundle?.taskIds, bundleId, taskId).then(taskBundle => {
this.setState({taskBundle, loading: false})
})
}

clearActiveTaskBundle = () => {
this.setState({selectedTasks: [], taskBundle: null, loading: false})
this.resetSelectedTasks()

clearActiveTaskBundle = async (bundleId) => {
try {
const bundleDeleted = await this.props.deleteTaskBundle(bundleId)

Check warning on line 218 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L216-L218

Added lines #L216 - L218 were not covered by tests
if (bundleDeleted) {
this.setState({

Check warning on line 220 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L220

Added line #L220 was not covered by tests
selectedTasks: [],
taskBundle: null,
loading: false
})
this.resetSelectedTasks()

Check warning on line 225 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L225

Added line #L225 was not covered by tests
}
} catch (error) {
console.error("Error clearing active task bundle:", error)
this.setState({loading: false})

Check warning on line 229 in src/components/HOCs/WithTaskBundle/WithTaskBundle.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskBundle/WithTaskBundle.js#L228-L229

Added lines #L228 - L229 were not covered by tests
}
}

setCompletingTask = task => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
updateMapMarkers() {
const markers = _map(this.props.taskClusters, cluster => {
const cluserStatus = cluster.status ?? cluster.taskStatus
const clusterId = cluster.id ?? cluster.taskId
const clusterId = cluster.id ?? cluster.taskId
const alreadyBundled = cluster.bundleId && !this.props.taskBundle?.bundleId !== cluster.bundleId

const bundleConflict = Boolean(
clusterId &&
(clusterId &&

Check warning on line 41 in src/components/HOCs/WithTaskClusterMarkers/WithTaskClusterMarkers.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskClusterMarkers/WithTaskClusterMarkers.js#L41

Added line #L41 was not covered by tests
this.props.task &&
![0, 3, 6].includes(cluserStatus) &&
!this.props.taskBundle?.taskIds?.includes(clusterId) &&
!this.props.initialBundle?.taskIds?.includes(clusterId)
!this.props.initialBundle?.taskIds?.includes(clusterId)) ||
alreadyBundled

Check warning on line 46 in src/components/HOCs/WithTaskClusterMarkers/WithTaskClusterMarkers.js

View check run for this annotation

Codecov / codecov/patch

src/components/HOCs/WithTaskClusterMarkers/WithTaskClusterMarkers.js#L45-L46

Added lines #L45 - L46 were not covered by tests
)

return AsMappableCluster(cluster).mapMarker(
Expand Down
9 changes: 8 additions & 1 deletion src/components/InsetMap/InsetMap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { MapContainer, Marker, AttributionControl } from 'react-leaflet'
import { MapContainer, Marker, AttributionControl, useMap} from 'react-leaflet'
import SourcedTileLayer from '../EnhancedMap/SourcedTileLayer/SourcedTileLayer'
import { layerSourceWithId,
defaultLayerSource } from '../../services/VisibleLayer/LayerSources'
Expand All @@ -13,6 +13,12 @@
const layerSource =
layerSourceWithId(this.props.layerSourceId) || defaultLayerSource()

const ResizeMap = () => {
const map = useMap();
map.invalidateSize();
return null;

Check warning on line 19 in src/components/InsetMap/InsetMap.js

View check run for this annotation

Codecov / codecov/patch

src/components/InsetMap/InsetMap.js#L16-L19

Added lines #L16 - L19 were not covered by tests
};

return (
<div className={classNames("inset-map", this.props.className)}>
<MapContainer
Expand All @@ -25,6 +31,7 @@
attributionControl={false}
maxBounds={[[-90, -180], [90, 180]]}
>
<ResizeMap />
<AttributionControl position="bottomleft" prefix={false} />
<SourcedTileLayer source={layerSource} skipAttribution={true} />
<Marker
Expand Down
7 changes: 7 additions & 0 deletions src/components/SupplementalMap/SupplementalMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
)
}

const ResizeMap = () => {
const map = useMap();
map.invalidateSize();
return null;

Check warning on line 96 in src/components/SupplementalMap/SupplementalMap.js

View check run for this annotation

Codecov / codecov/patch

src/components/SupplementalMap/SupplementalMap.js#L94-L96

Added lines #L94 - L96 were not covered by tests
};

const SupplementalMap = (props) => {
const zoom = _get(props, "task.parent.defaultZoom", DEFAULT_ZOOM)
const minZoom = _get(props, "task.parent.minZoom", MIN_ZOOM)
Expand All @@ -108,6 +114,7 @@
attributionControl={false}
maxBounds={[[-90, -180], [90, 180]]}
>
<ResizeMap />
<AttributionControl position="bottomleft" prefix={false} />
<SupplementalMapContent {...props} />
</MapContainer>
Expand Down
Loading