ui icon indicating copy to clipboard operation
ui copied to clipboard

UAlert description slot in div

Open cco3 opened this issue 1 year ago • 6 comments

Description

Trying to place a div in a UAlert leads to hydration mismatches because both the #title and #description are p tags.

It's not clear to me that the #description should be in a p tag; and it'd be nice to put more substantial content inside an alert.

Additional context

Related issue

cco3 avatar Mar 22 '24 21:03 cco3

I'm not fully sure to follow you here: would you like explicitly note in the docs that the #description slot is a p tag, or would you more prefer it to be a div?

sandros94 avatar Mar 23 '24 11:03 sandros94

I'm suggesting that it be a div so that I could nest other divs in it. I'm happy to defer to someone who has a better sense of these things, but I can imagine an alert being used for items more substantial than just phrasing content.

cco3 avatar Mar 23 '24 18:03 cco3

I've opened a PR to add a default slot to the UAlert component.

This makes us not break the current functionality but adds the ability to insert custom components or code.

sandros94 avatar Mar 24 '24 11:03 sandros94

I agree that having divs for descriptions would allow more possibilities but wouldn't that worsen SEO?

benjamincanac avatar Mar 25 '24 10:03 benjamincanac

@benjamincanac cant we just do a dynamic component with default as p tag and document it? Think this would be good as it is what people are most used to adding default tract in slot instead of as prop. Thoughts

moshetanzer avatar Mar 31 '24 09:03 moshetanzer

Here is how I fixed in in v3, example for the Toast component here: https://github.com/benjamincanac/ui3/blob/dev/src/runtime/components/Toast.vue#L84-L89

benjamincanac avatar Apr 12 '24 12:04 benjamincanac