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 popup handlers and removing graphics #183

Merged
merged 3 commits into from
Jun 21, 2023

Conversation

TimPurdum
Copy link
Collaborator

Closes #181
Closes #182

Allows user to remove a graphic successfully from the MapView
Prevents multiple registrations of the event handler in a PopupWidget or PopupTemplate

@TimPurdum TimPurdum self-assigned this Jun 15, 2023
@@ -227,7 +227,13 @@ export function buildJsPopupTemplate(popupTemplateObject: DotNetPopupTemplate, v
if (viewId !== null) {
let view = arcGisObjectRefs[viewId] as View;
if (hasValue(view)) {
view.popup.on("trigger-action", async (event: PopupTriggerActionEvent) => {
if (hasValue(triggerActionHandler)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to start to convert more null checks over to 'hasValue'? I see you have included this multiple times here and above, but still have the null checks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would be a good refactoring to do, to move to always using hasValue.

@@ -1533,21 +1533,14 @@ public async Task SolveServiceArea(string serviceAreaUrl, double[] driveTimeCutO
/// </param>
public async Task RemoveGraphic(Graphic graphic)
{
try
Copy link
Collaborator

Choose a reason for hiding this comment

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

why remove the try/catch? just to match up with the other layer and graphic methods above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This try/catch was swallowing the exception and not exposing it to the end user, even though there was a real problem. I sometimes intentionally swallow exceptions when they are caused by say a user navigating away from the map, but in this case it was misguided.

Copy link
Collaborator

@seahro seahro left a comment

Choose a reason for hiding this comment

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

Looks good one question about the hasValue vs null checks.

@TimPurdum TimPurdum merged commit 9ac74eb into develop Jun 21, 2023
@TimPurdum TimPurdum deleted the bug/181_182_remove_graphics_and_popup_handlers branch June 21, 2023 16:13
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.

Popup Action Handlers added repeatedly Swallowed exception and failure on MapView.RemoveGraphic
2 participants