-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[maps] fix drawing shapes #74689
[maps] fix drawing shapes #74689
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,15 @@ export class MapsAppView extends React.Component { | |
} | ||
|
||
_hasUnsavedChanges() { | ||
return this.props.hasUnsavedChanges(this.props.savedMap, this.state.initialLayerListConfig); | ||
const savedLayerList = this.props.savedMap.getLayerList(); | ||
return !savedLayerList | ||
? !_.isEqual(this.props.layerListConfigOnly, this.state.initialLayerListConfig) | ||
: // savedMap stores layerList as a JSON string using JSON.stringify. | ||
// JSON.stringify removes undefined properties from objects. | ||
// savedMap.getLayerList converts the JSON string back into Javascript array of objects. | ||
// Need to perform the same process for layerListConfigOnly to compare apples to apples | ||
// and avoid undefined properties in layerListConfigOnly triggering unsaved changes. | ||
!_.isEqual(JSON.parse(JSON.stringify(this.props.layerListConfigOnly)), savedLayerList); | ||
} | ||
|
||
_setBreadcrumbs = () => { | ||
|
@@ -356,22 +364,20 @@ export class MapsAppView extends React.Component { | |
); | ||
} | ||
|
||
render() { | ||
const { filters, isFullScreen } = this.props; | ||
_addFilter = (newFilters) => { | ||
newFilters.forEach((filter) => { | ||
filter.$state = { store: esFilters.FilterStateStore.APP_STATE }; | ||
}); | ||
this._onFiltersChange([...this.props.filters, ...newFilters]); | ||
}; | ||
|
||
render() { | ||
return this.state.initialized ? ( | ||
<div id="maps-plugin" className={isFullScreen ? 'mapFullScreen' : ''}> | ||
<div id="maps-plugin" className={this.props.isFullScreen ? 'mapFullScreen' : ''}> | ||
{this._renderTopNav()} | ||
<h1 className="euiScreenReaderOnly">{`screenTitle placeholder`}</h1> | ||
<div id="react-maps-root"> | ||
<MapContainer | ||
addFilters={(newFilters) => { | ||
newFilters.forEach((filter) => { | ||
filter.$state = { store: esFilters.FilterStateStore.APP_STATE }; | ||
}); | ||
this._onFiltersChange([...filters, ...newFilters]); | ||
}} | ||
/> | ||
<MapContainer addFilters={this._addFilter} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed that extracting this adds clarity, but isn't this functionally equivalent? The lambda makes sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are functionally equivalent. The change is that the original code created a new function on every render. The new code uses the same function reference on every render. This is important because down stream |
||
</div> | ||
</div> | ||
) : null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for removing some indirection