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

feat(POI maps): add navigation controls for multi features popup #209

Merged
merged 11 commits into from
Jan 24, 2024

Conversation

RafaelSzmarowski
Copy link
Contributor

@RafaelSzmarowski RafaelSzmarowski commented Dec 5, 2023

Summary

The goal for this PR is to test a simple implementation to add navigation controls inside the popup when the click event query multiple features.

(Internal for Opendatasoft only) Associated Shortcut ticket: sc-44648.

Screen.Recording.2024-01-11.at.11.39.50.mov

Native Popup close button has been removed to add a custom arrow which is at the same level of the navigation buttons.

We also update how a feature is highlight. Highlight and un-highlight strategies are different for each layer type. Currently, only 'symbol' and 'circle' has highlight and un-highlight strategies.

There is a small glitch when a symbol feature is selected: the layer flickers. I didn't find why, but I think this is acceptable.

Review checklist

  • Description is complete
  • Commits respect the Conventional Commits Specification
  • 2 reviewers (1 if trivial)
  • Tests coverage has improved
  • Code is ready for a release on NPM

@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-44895/sdk-poi-map-small-improvements-for-tooltip branch from 4416f54 to dcf0585 Compare December 6, 2023 08:42
Base automatically changed from feature/sc-44895/sdk-poi-map-small-improvements-for-tooltip to main December 6, 2023 14:00
@RafaelSzmarowski RafaelSzmarowski changed the title feat(POI maps): add navigation controls for multi features popup POC: feat(POI maps): add navigation controls for multi features popup Dec 7, 2023
@RafaelSzmarowski RafaelSzmarowski marked this pull request as ready for review December 7, 2023 09:44
@KevinFabre-ods KevinFabre-ods force-pushed the feature/navigate-among-features-in-popup branch from d03deee to d42abd1 Compare December 7, 2023 10:07
Copy link
Contributor

@KevinFabre-ods KevinFabre-ods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ✨

I don't see anything that could block this POC.

IMO We should also generate the close button in the same function that generate the arrow buttons

return;
}

// FIXME: remove eslint comment.
// eslint-disable-next-line prefer-destructuring
this.activeFeature = features[0];

this.availableFeaturesOnClick = features;
Copy link
Contributor

@KevinFabre-ods KevinFabre-ods Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As popup is an optional configuration for a layer we must filter availableFeaturesOnClick with only features that has a popup config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, indeed the close button should be part of the same row as the navigation controls, I think. And good catch for the this filter. I'll do the changes if everyone agrees for this first implementation 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here 7531261

@RafaelSzmarowski
Copy link
Contributor Author

Another thing that I wasn't unsure and wanted to double check with you, is the change from setHtml to setDomContent safe enough, as far as I've read, there shouldn't be any change in terms of security. I mean both are XSS unsafe and should be handled by user to make sure the content passed to the popup is sanitize.

@KevinFabre-ods
Copy link
Contributor

Another thing that I wasn't unsure and wanted to double check with you, is the change from setHtml to setDomContent safe enough, as far as I've read, there shouldn't be any change in terms of security. I mean both are XSS unsafe and should be handled by user to make sure the content passed to the popup is sanitize.

Yes, nothing changes, the value returned by getContent cannot be controlled.
It's up to the developer using the SDK component to be vigilant.

@etienneburdet
Copy link
Contributor

I kinda think the popup can be its own Svelte component already, without much modifications to Map.ts actually. If updatePopupContent takes a callback, we can use that callback to update a let availableFeatures and then have some {#if availableFeatures} <Popup {availableFeatures} /> {/if} and then we can do everything inside the popup component I think.

That would be one less thing to migrate and unless I miss something, not as much work as it seems in the first place.

@KevinFabre-ods
Copy link
Contributor

I kinda think the popup can be its own Svelte component already, without much modifications to Map.ts actually. If updatePopupContent takes a callback, we can use that callback to update a let availableFeatures and then have some {#if availableFeatures} <Popup {availableFeatures} /> {/if} and then we can do everything inside the popup component I think.

That would be one less thing to migrate and unless I miss something, not as much work as it seems in the first place.

@etienneburdet If a Svelte component controls the popup instance we must remove the 'popup' variable declaration in the Map.ts file.
This requires to move the updatePopupContent and updatePopupDisplay functions in the Popup component. Also when a popup is closed, we must update a map feature state to change how big a point is.

IMO all these changes required to completely rework on how the information is circulating between popup and map instance and should be done during our migration to Svelte components.

@KevinFabre-ods KevinFabre-ods marked this pull request as draft January 10, 2024 17:44
@KevinFabre-ods KevinFabre-ods force-pushed the feature/navigate-among-features-in-popup branch 3 times, most recently from d96cd8f to e47738f Compare January 11, 2024 10:31
@KevinFabre-ods KevinFabre-ods changed the title POC: feat(POI maps): add navigation controls for multi features popup feat(POI maps): add navigation controls for multi features popup Jan 11, 2024
@KevinFabre-ods KevinFabre-ods marked this pull request as ready for review January 11, 2024 10:46
@KevinFabre-ods
Copy link
Contributor

@RafaelSzmarowski I can't assign you as reviewer but can you please review it.
Since your work, I updated the code based on the comments we shared.

@RafaelSzmarowski
Copy link
Contributor Author

RafaelSzmarowski commented Jan 12, 2024

@RafaelSzmarowski I can't assign you as reviewer but can you please review it. Since your work, I updated the code based on the comments we shared.

Thanks for the last changes and for taking care of this PR ! As far as I have tested it, it looks very well and the code LGTM 🏅 Nice work !

@KevinFabre-ods
Copy link
Contributor

Seen with the design team to always show the navigation controls. So controls must be visible when the content is loading
Done in 4610afa

Screen.Recording.2024-01-16.at.16.54.25.mov

Copy link
Contributor

@etienneburdet etienneburdet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me if we migrate that to a Svelte component later 👌

packages/visualizations/src/components/MapPoi/Map.ts Outdated Show resolved Hide resolved
@KevinFabre-ods KevinFabre-ods force-pushed the feature/navigate-among-features-in-popup branch from 4610afa to d237fc2 Compare January 24, 2024 11:33
@KevinFabre-ods KevinFabre-ods merged commit 5c6f91b into main Jan 24, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants