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

Feature #847: Add close button to QR popover #1104

Conversation

sadiqkhoja
Copy link
Contributor

@sadiqkhoja sadiqkhoja commented Dec 13, 2024

Closes getodk/central#847

Changes:

  • Hide popover on click of a button that has data-closes-popover attribute
  • Hide popover on escape key as well
  • Added button in QR panel to hide popover (self)

What has been done to verify that this works as intended?

Tried in chrome and added fews tests.

Why is this the best possible solution? Were any other approaches considered?

Because popover component adds click eventListener on the document that useCapture, I was not able to handle vue events directly on qr-panel component. Having another condition in closeAfterClick that checks if the event target is a close button, identified by data-closes-popover attribute, seems reasonable to me.

I have also added event listener for escape key, which is applicable on all popover. If we want we can add a prop to add it on selective popovers - like maybe we don't hide hover-cards on escape 🤷‍♂️.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

I don't see any regression risks here.

Does this change require updates to user documentation? If so, please file an issue here and include the link below.

No

Before submitting this PR, please make sure you have:

  • run npm run test and npm run lint and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

Copy link
Member

@matthew-white matthew-white left a comment

Choose a reason for hiding this comment

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

This is looking good. 👍 Once we complete #1084, maybe we could see if there's a different approach we could take than the data-closes-popover attribute. But I think it makes a lot of sense given how the Bootstrap plugin works.

},
beforeUnmount() {
if (this.target != null) this.hide();
document.removeEventListener('click', this.hideAfterClick, true);
window.removeEventListener('resize', this.hideAfterResize);
document.addEventListener('keydown', this.hideAfterEsc);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
document.addEventListener('keydown', this.hideAfterEsc);
document.removeEventListener('keydown', this.hideAfterEsc);

@matthew-white
Copy link
Member

matthew-white commented Dec 13, 2024

If we want we can add a prop to add it on selective popovers - like maybe we don't hide hover-cards on escape 🤷‍♂️.

It seems OK to me to hide hover cards as well. We could always add that selective logic later if we need to.

* Hide popover on click of a button that has data-closes-popover attribut
* Hide popover on escape key as well
@sadiqkhoja sadiqkhoja force-pushed the features/847-show-close-button-for-qr-code branch from 8955def to 9809ae6 Compare December 14, 2024 06:05
@sadiqkhoja sadiqkhoja merged commit 59cc444 into getodk:master Dec 14, 2024
1 check 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.

Testing QR code flyout without option to close it
2 participants