maitrungduc1410 / primeng-shadowdom-directives

Directives that make PrimeNG plays nicely with ShadowDOM
https://maitrungduc1410.github.io/primeng-shadowdom-directives/
MIT License
12 stars 3 forks source link

p-autocomplete with dropdown true #11

Closed antoniomolinadev closed 1 year ago

antoniomolinadev commented 1 year ago

Hi,

Today I'm testing the p-autocomplete with dropdown and I can't show the items when you click in the button. I detected that open and close the overlay at the same time and disnt't appear any error message.

I tried to remove the shadowDom and works fine. I'm not sure what it's happened and why the overlay open and close at the same time with shadowDom activated.

Is possible to add a fix for use the p-autocomplete with priming-shadowdom-directives?

Thank a lot!

antoniomolinadev commented 1 year ago

Hi,

Finally i fixed it. My code:

hostEl.bindDocumentClickListener = () => { if (!hostEl.documentClickListener) { const documentTarget: any = hostEl.el ? hostEl.el.nativeElement.ownerDocument.activeElement.shadowRoot ?hostEl.el.nativeElement.ownerDocument.activeElement.shadowRoot: hostEl.el.nativeElement.ownerDocument : 'document'; hostEl.documentClickListener = hostEl.renderer.listen(documentTarget, 'click', (event) => { if (event.which === 3) { return; } if (!hostEl.inputClick && !hostEl.isDropdownClick(event)) { hostEl.hide(); } hostEl.inputClick = false; hostEl.cd.markForCheck(); }); } } } }

If you want to add to autocomplete.ts, could fix the dropdown overlay in p-autocomplete.

You can close this issue.

Regards

maitrungduc1410 commented 1 year ago

Hi, please upgrade to v0.2.1 I fixed the issue. Commit

The reason for this is: in the case we render autocomplete in multiple nested shadow Root, it always find the very top level shadow root, but instead it should find in its current shadow root only