You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm integrating Autocomplete into an environment with aggressive global CSS (a WordPress theme). To avoid style conflicts, I need to use Shadow DOM for proper isolation.
However, the current implementation of detached mode prevents this.
The Problem:
The detached mode ignores the root: shadowRoot passed to getEnvironmentProps and always appends the .aa-DetachedOverlay to document.body. This breaks encapsulation and causes two main issues:
Broken Styles: The UI is affected by global CSS.
Broken Functionality: Buttons (like 'Cancel') and event listeners fail because the library can't find elements inside the Shadow DOM.
Minimal Reproduction Code:
<scriptsrc="https://cdn.jsdelivr.net/npm/@algolia/autocomplete-js@1/dist/umd/index.production.js"></script><divid="autocomplete-host"></div><script>consthost=document.querySelector('#autocomplete-host');constshadow=host.attachShadow({mode: 'open'});constautocompleteContainer=document.createElement('div');shadow.appendChild(autocompleteContainer);constlink=document.createElement('link');link.rel='stylesheet';link.href='https://cdn.jsdelivr.net/npm/@algolia/autocomplete-theme-classic@1/dist/theme.min.css';shadow.appendChild(link);window['@algolia/autocomplete-js'].autocomplete({container: autocompleteContainer,detachedMediaQuery: 'all',// Force detached modegetEnvironmentProps: ()=>({root: shadow}),// Set Shadow DOM as the rootgetSources: ()=>[{sourceId: 'test',getItems: ()=>[{name: 'Item 1'}]}]});</script>
My Request:
Could you please update the detached mode to render its overlay inside the provided root from getEnvironmentProps?
This fix is essential for developers who need to build encapsulated components.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Algolia Team,
I'm integrating Autocomplete into an environment with aggressive global CSS (a WordPress theme). To avoid style conflicts, I need to use Shadow DOM for proper isolation.
However, the current implementation of
detached
mode prevents this.The Problem:
The
detached
mode ignores theroot: shadowRoot
passed togetEnvironmentProps
and always appends the.aa-DetachedOverlay
todocument.body
. This breaks encapsulation and causes two main issues:Minimal Reproduction Code:
My Request:
Could you please update the
detached
mode to render its overlay inside the providedroot
fromgetEnvironmentProps
?This fix is essential for developers who need to build encapsulated components.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions