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: Replace deprecated DOMNodeInserted with MutationObserver for Algolia DocSearch initialization #17424

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

agneszitte
Copy link
Contributor

@agneszitte agneszitte commented Jul 8, 2024

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The Algolia search box for the documentation is no longer visible in canary browsers, and a similar behavior is expected in upcoming stable browser versions when using the deprecated DOMNodeInserted.

image

What is the new behavior?

The Algolia search box for the documentation is visible for all browser versions using MutationObserver as a replacement for the deprecated DOMNodeInserted.

image

Changes Summary

Important

Currently, DOMNodeInserted is deprecated and triggers a warning in stable browser versions (126.0.x.x) but has already been disabled and throws an error in the latest canary versions (127.0.x.x and above).
Mutation event support will be disabled by default starting in Chrome 127, around July 30, 2024.
For more information: Chrome Status.

Replaced deprecated DOMNodeInserted with MutationObserver for Algolia DocSearch initialization:

  • Removed deprecated DOMNodeInserted event listener.
  • Implemented MutationObserver to monitor changes in the DOM and initialize DocSearch when the #docsearch element is added.
  • Added error handling for better debugging.
  • Ensured observation starts only after the DOM is fully loaded.
  • Included comments for better code understanding and future updates.

Changes tested with latest versions of:

  • Chrome (Stable, Dev, Canary)
  • Edge (Stable, Dev, Canary)
  • Firefox (Stable, Dev, Nightly)
  • Safari (Stable)

PR Checklist

Please check if your PR fulfills the following requirements:

@agneszitte agneszitte marked this pull request as draft July 8, 2024 18:42
@agneszitte
Copy link
Contributor Author

@Mergifyio backport release/stable/5.2

@agneszitte
Copy link
Contributor Author

@Mergifyio backport release/stable/5.3

Copy link
Contributor

mergify bot commented Jul 8, 2024

backport release/stable/5.2

✅ Backports have been created

Copy link
Contributor

mergify bot commented Jul 8, 2024

backport release/stable/5.3

✅ Backports have been created

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

@agneszitte agneszitte added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2024
Copy link
Member

@carldebilly carldebilly left a comment

Choose a reason for hiding this comment

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

LGTM

@agneszitte agneszitte force-pushed the dev/agzi/FixDeprecatedDOMNodeInserted branch 2 times, most recently from dc76100 to d03e516 Compare July 8, 2024 23:38
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

@agneszitte agneszitte force-pushed the dev/agzi/FixDeprecatedDOMNodeInserted branch from d03e516 to 7f03de9 Compare July 9, 2024 00:40
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

@agneszitte agneszitte force-pushed the dev/agzi/FixDeprecatedDOMNodeInserted branch from 7f03de9 to 22ef577 Compare July 9, 2024 01:37
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

@agneszitte agneszitte marked this pull request as ready for review July 9, 2024 02:17
@agneszitte agneszitte removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 9, 2024
@agneszitte agneszitte marked this pull request as draft July 9, 2024 02:38
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

1 similar comment
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

…olia DocSearch initialization

- Removed deprecated DOMNodeInserted event listener
- Implemented MutationObserver to monitor changes in the DOM
- Added error handling for better debugging
- Ensured observation starts only after DOM is fully loaded
- Included comments for better code understanding and future updates
@agneszitte agneszitte force-pushed the dev/agzi/FixDeprecatedDOMNodeInserted branch from 2ba7ac4 to 860bf6b Compare July 9, 2024 04:27
@agneszitte agneszitte marked this pull request as ready for review July 9, 2024 04:28
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-17424/index.html

@agneszitte agneszitte merged commit d67dab2 into master Jul 9, 2024
15 checks passed
@agneszitte agneszitte deleted the dev/agzi/FixDeprecatedDOMNodeInserted branch July 9, 2024 15:21
agneszitte added a commit that referenced this pull request Jul 9, 2024
…5.3/pr-17424

fix: Replace deprecated DOMNodeInserted with MutationObserver for Algolia DocSearch initialization (backport #17424)
agneszitte added a commit that referenced this pull request Jul 9, 2024
…5.2/pr-17424

fix: Replace deprecated DOMNodeInserted with MutationObserver for Algolia DocSearch initialization (backport #17424)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants