vue3-popper icon indicating copy to clipboard operation
vue3-popper copied to clipboard

Is there a way to avoid slot wrapper?

Open osbre opened this issue 3 years ago • 7 comments

Hi. Thank you for this great component!

But, it makes additional <div> on top of my slot content.

Question: Is there a way to avoid this? (Use default slot directly, not in the wrapper)

Thanks!

https://github.com/valgeirb/vue3-popper/blob/9306f8d4a1842b41c1afa49c7d7e371bc0c7a420/src/component/Popper.vue#L3-L15

osbre avatar Jul 12 '21 12:07 osbre

Is the extra div causing problems? I could try moving all the events etc. to the outermost div - I'll let you know how that goes 👍🏻

valgeirb avatar Jul 12 '21 13:07 valgeirb

In my case, it causes problems with styles BTW thanks for reaching out

osbre avatar Jul 12 '21 13:07 osbre

This is causing some unwanted issues, what is your styling problem exactly?

valgeirb avatar Jul 12 '21 14:07 valgeirb

I also found an issue with styles in particular the elements inside the Popper would no longer take on the full width of the parent element.

timmaier avatar Jul 23 '21 04:07 timmaier

@timmaier Yes, the default slot of the Popper is wrapped with an inline-block, this is so that you can't activate the Popper when clicking "outside" of the wrapped element.

Here's a demo with the inline-block style removed (so that the element takes up the full width of the parent element) with some borders to make things clearer:

demo

I just feel that this could confuse people and you can always add width: 100% to your button to make it full width.

That said, if you have any suggestions I'm all ears 👍🏻

Edit: All that said, the class="inline-block" should probably be on the outermost div, I'll poke at this some more...

valgeirb avatar Jul 23 '21 13:07 valgeirb

Sorry for hijacking this issue, but a way of getting rid of the wrapper, or at least defining the tag of the wrapper would be much appreciated. I have a use case where user generated content comes from a database. The content contains HTML and is wrapped in

tags. Inside of the content I am transforming parts of it to render popovers, however since vue3-popper renders a div, and a div is invalid within paragraphs, it leads to hydration issues in a SSR context.

thplat avatar Feb 27 '22 19:02 thplat

Was there any solution to this one? I think the ability to apply modifiers - specifically the applyStyles (https://popper.js.org/docs/v2/modifiers/apply-styles/) - would be helpful here in allowing users to override the class="inline-block".

Unfortunately the class="inline-block" seems to have an arbitrary width in my use case and doesn't respond to the 100% width of it's immediate child, nor extend to the width of it's parent.

ThorntonStuart avatar Aug 11 '22 16:08 ThorntonStuart