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

Search: Clicking outside overlay closes overlay #22690

Merged
merged 8 commits into from
Feb 10, 2022

Conversation

jsnmoon
Copy link
Member

@jsnmoon jsnmoon commented Feb 5, 2022

Fixes #18937.

Changes proposed in this Pull Request:

Adds an event handler on the window checking for clicks outside the search overlay.

Does this pull request change what data or activity we track or use?

None.

Testing instructions:

  • Apply this change to a site with a Jetpack Search subscription and Instant Search enabled.
  • Perform a site search e.g. /?s=page`.
  • Click outside the overlay.
  • Ensure that the overlay closes as expected.

@jsnmoon jsnmoon added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Search For all things related to Search [Status] Needs Team Review [Package] Search Contains core Search functionality for Jetpack and Search plugins labels Feb 5, 2022
@jsnmoon jsnmoon self-assigned this Feb 5, 2022
@jsnmoon jsnmoon requested a review from a team as a code owner February 5, 2022 00:15
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: March 1, 2022.
  • Scheduled code freeze: February 22, 2022.

@jsnmoon jsnmoon force-pushed the fix/close-search-overlay-on-outside-click branch from 6f8492a to b30dbef Compare February 5, 2022 00:17
@jsnmoon jsnmoon changed the title Search: Clicking outside now closes overlay Search: Clicking outside overlay closes overlay Feb 5, 2022
Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

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

It works as described, good job 👍 One potential typo and suggested a change.

Co-authored-by: Jasper Kang <jasper.kang@automattic.com>
@jsnmoon jsnmoon requested a review from kangzj February 8, 2022 22:47
Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

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

I noticed when you open and close the overlay for several times, it causes the browser to hang. Profiled the process, it seems the click event is taking longer each time.

image

Possibly this is related - we should get the element dynamically instead of storing a static handle even it saves some calculations - the element could be destroyed and re-rendered which is causing objects not released?

@jsnmoon
Copy link
Member Author

jsnmoon commented Feb 9, 2022

I noticed when you open and close the overlay for several times, it causes the browser to hang. Profiled the process, it seems the click event is taking longer each time.

Possibly this is related - we should get the element dynamically instead of storing a static handle even it saves some calculations - the element could be destroyed and re-rendered which is causing objects not released?

Good catch. I'm not able to replicate, but it might have been caused by the resultsContainer value never getting garbage collected upon rapid summon/dismissal of the search overlay. I went ahead and tweaked the click event handler logic.

@jsnmoon jsnmoon requested a review from kangzj February 9, 2022 00:40
kangzj
kangzj previously approved these changes Feb 9, 2022
Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

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

Good job it works perfectly and code looks good to me 👍

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Feb 9, 2022
Copy link
Contributor

@annacmc annacmc left a comment

Choose a reason for hiding this comment

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

Works great for me 👍

@jsnmoon jsnmoon added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Team Review labels Feb 9, 2022
@jsnmoon jsnmoon requested a review from a team February 9, 2022 23:29
@jsnmoon
Copy link
Member Author

jsnmoon commented Feb 9, 2022

Hi @jeherve, just wanted to make sure #22461 is working as expected. In this PR, we're making a minor enhancement to the Search package, resulting in a version bump. This version bump is then propagated to Jetpack's composer.json, which triggers the Jetpack and packages section of the required review check.

Although requiring Crew reviews for packages affecting the Jetpack plugin makes sense, it also means #22461 won't really be useful because any changes (major or minor or patch [EDIT: Patch versions are ignored for local .x-dev pseudo versions, as noted in another comment below]) will bump Jetpack's composer.json and will necessitate Crew review 🙃

@anomiex
Copy link
Contributor

anomiex commented Feb 10, 2022

(major, minor, or patch)

Major or minor, but not patch as a patch bump would not result in a change the "0.8.x-dev" pseudo-version.

Unfortunately the check works on the file level, so we can't specify that certain changes to Jetpack's composer.json are ok while others are not.

@jeherve jeherve added this to the jetpack/10.7 milestone Feb 10, 2022
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 10, 2022
@jeherve jeherve enabled auto-merge (squash) February 10, 2022 16:56
@jeherve jeherve merged commit 90675f2 into master Feb 10, 2022
@jeherve jeherve deleted the fix/close-search-overlay-on-outside-click branch February 10, 2022 16:56
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Feb 10, 2022
gavande1 pushed a commit that referenced this pull request Feb 16, 2022
Co-authored-by: Jasper Kang <jasper.kang@automattic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search [Package] Search Contains core Search functionality for Jetpack and Search plugins [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search: Clicking outside the overlay should close the modal
5 participants