-
Notifications
You must be signed in to change notification settings - Fork 391
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
#10545: Option to disable identify popup in case of no results #10557
base: master
Are you sure you want to change the base?
Conversation
… results Description: - handle adding an option called 'hidePopupIfNoResults' to hide the identify popup - add unit tests - add jsdoc
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.
there is something unclear to me with the current implementation as i have not yet tested it.
will do another set of review later on, for now i leave some comments as a reminder
@@ -91,6 +93,9 @@ export const identifyLifecycle = compose( | |||
showAllResponses, | |||
highlight: pluginCfg?.highlightEnabledFromTheStart || false | |||
}); | |||
if (hidePopupIfNoResults) { | |||
enableHideEmptyPopupOption(true); |
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.
can't you just use the hidePopupIfNoResults prop instead of calling enableHideEmptyPopupOption and updating state?
(state) => state.mapPopups && state.mapPopups.hideEmptyPopupOption || false, | ||
isMouseMoveActiveSelector, | ||
mapInfoRequestsSelector, | ||
responsesSelector, | ||
(popups, hideEmptyPopupOption, isMouseMoveActive, mapInfoRequests, mapInfoResponses) => { | ||
// create a flag for hide the identify popup in case no results in hover mode | ||
let identifyPopupHidden = false; | ||
if (isMouseMoveActive && mapInfoRequests?.length && mapInfoResponses?.length && hideEmptyPopupOption) { | ||
const format = getDefaultInfoFormatValue(); | ||
const invalidResponses = getValidator(format).getNoValidResponses(mapInfoResponses); | ||
const emptyResponses = mapInfoRequests?.length === invalidResponses?.length; | ||
const missingResponses = (mapInfoRequests || []).length - (mapInfoResponses || []).length; | ||
identifyPopupHidden = missingResponses === 0 && emptyResponses && isMouseMoveActive && hideEmptyPopupOption; | ||
} | ||
return { | ||
popups, | ||
identifyPopupHidden |
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.
I have also some doubts here tbh, i will deeply check this
(popups) => ({ | ||
popups | ||
})), { | ||
(state) => state.mapPopups && state.mapPopups.hideEmptyPopupOption || false, |
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.
a dedicated selector must be created when you add a new one
const {identifyPopupHidden} = this.props; | ||
if (identifyPopupHidden) { | ||
(this._popups || []).forEach(({popup}) => { | ||
popup.off('remove', this.popupClose); | ||
popup && this.props.map.removeLayer(popup); | ||
}); | ||
return []; | ||
} | ||
return this.preparePopups() |
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.
i have some doubts about this implementation too.
@@ -59,6 +61,14 @@ export default class PopupSupport extends React.Component { | |||
this.props.onPopupClose(id); | |||
} | |||
renderPopups = () => { | |||
const {identifyPopupHidden, map} = this.props; | |||
if (identifyPopupHidden) { |
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.
maybe the flag hidePopupIfNoResults could have been used to filter out elements?
i have to debug this tbh
Description
In this PR, it is implemented adding an option for identify plugin called 'hidePopupIfNoResults' = true to handle hide identify popup in case of no results for 'openlayers' and 'leaflet' for 2D maps.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
#10545
What is the current behavior?
#10545
What is the new behavior?
If 'hidePopupIfNoResults' is added to cfg in identify plugin by true ---> the identify popup will be hidden if there is no results.
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)
Other useful information
To test it, for desktop add 'hidePopupIfNoResults' with true for cfg in identify plugin.
For mobile, you need to add the identify plugin option 'hidePopupIfNoResults' with true for cfg and edit ---> DEFAULT_VISUALIZATION_MODES_CONFIG.[VisualizationModes._2D].mobile to
MapLibraries.LEAFLET
in this part belowMapStore2/web/client/utils/MapTypeUtils.js
Lines 27 to 36 in 6c8e852