svelteuidev / svelteui

SvelteUI Monorepo
https://svelteui.dev
MIT License
1.3k stars 62 forks source link

Validation error "Element div not allowed as child of element button in this context" in Menu #331

Open BeeMargarida opened 1 year ago

BeeMargarida commented 1 year ago

What package has an issue

@svelteuidev/core

A clear and concise description of what the bug is

Creating this issue so that it's not forgotten.

Raised in https://discord.com/channels/954790377754337280/1082395387446427789/1082434208972152892

All Menu Items (and also Tab) contain a button with a div inside. Buttons can only have inline elements inside.

In which browser(s) did the problem occur?

No response

Steps To Reproduce

-

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Relevant Assets

No response

schindld commented 1 year ago

If it helps, here is the patch I created to get rid of the validation errors for the subset of components I've used so far (for @svelteuidev/core 0.10.0) (I know some issues have been fixed in the next-minor branch already):

diff --git a/node_modules/@svelteuidev/core/components/ActionIcon/ActionIcon.svelte b/node_modules/@svelteuidev/core/components/ActionIcon/ActionIcon.svelte
index d800517..480a5e2 100644
--- a/node_modules/@svelteuidev/core/components/ActionIcon/ActionIcon.svelte
+++ b/node_modules/@svelteuidev/core/components/ActionIcon/ActionIcon.svelte
@@ -50,7 +50,6 @@ Icon button to indicate secondary action.
    target={external ? '_blank' : null}
    rel={external ? 'noreferrer noopener' : null}
    {root}
-   {href}
    {...$$restProps}
 >
    {#if loading}
diff --git a/node_modules/@svelteuidev/core/components/ActionIcon/CloseButton/CloseButton.svelte b/node_modules/@svelteuidev/core/components/ActionIcon/CloseButton/CloseButton.svelte
index 65ca509..387ce5e 100644
--- a/node_modules/@svelteuidev/core/components/ActionIcon/CloseButton/CloseButton.svelte
+++ b/node_modules/@svelteuidev/core/components/ActionIcon/CloseButton/CloseButton.svelte
@@ -44,7 +44,6 @@ CloseButton is a premade ActionIcon with close icon
    {loaderProps}
    {loading}
    {disabled}
-   {href}
    {external}
    {...$$restProps}
 >
diff --git a/node_modules/@svelteuidev/core/components/Burger/Burger.svelte b/node_modules/@svelteuidev/core/components/Burger/Burger.svelte
index b568247..f94f014 100644
--- a/node_modules/@svelteuidev/core/components/Burger/Burger.svelte
+++ b/node_modules/@svelteuidev/core/components/Burger/Burger.svelte
@@ -18,5 +18,5 @@ $: ({ classes, getStyles, cx } = useStyles({ color: _color, size, opened }, { na
    class={cx(className, getStyles({ css: override }))}
    {...$$restProps}
 >
-   <div class={cx(classes.burger, { opened: opened })} />
+   <span class={cx(classes.burger, { opened: opened })} />
 </UnstyledButton>
diff --git a/node_modules/@svelteuidev/core/components/Button/Ripple.svelte b/node_modules/@svelteuidev/core/components/Button/Ripple.svelte
index 24b8d4d..51f340e 100644
--- a/node_modules/@svelteuidev/core/components/Button/Ripple.svelte
+++ b/node_modules/@svelteuidev/core/components/Button/Ripple.svelte
@@ -148,7 +148,7 @@
    });
 </script>

-<div class="ripple" bind:this={el} />
+<span class="ripple" bind:this={el} />

 <style>
    .ripple {
diff --git a/node_modules/@svelteuidev/core/components/Input/Input.svelte b/node_modules/@svelteuidev/core/components/Input/Input.svelte
index 98b732f..29967b6 100644
--- a/node_modules/@svelteuidev/core/components/Input/Input.svelte
+++ b/node_modules/@svelteuidev/core/components/Input/Input.svelte
@@ -70,7 +70,7 @@ Base component to create custom inputs

-->

-<Box {...wrapperProps} class={getStyles({ css: override })} {...$$restProps}> +<Box {...wrapperProps} class={getStyles({ css: override })}> {#if icon} <IconRenderer {icon} className={classes.icon} {...iconProps} iconSize={16} /> {/if} @@ -111,7 +111,6 @@ Base component to create custom inputs {disabled} {id} {autocomplete}

  • diff --git a/node_modules/@svelteuidev/core/components/Text/Text.svelte b/node_modules/@svelteuidev/core/components/Text/Text.svelte index ed3ee3c..1598c43 100644 --- a/node_modules/@svelteuidev/core/components/Text/Text.svelte +++ b/node_modules/@svelteuidev/core/components/Text/Text.svelte @@ -57,7 +57,6 @@ Display text and links with theme styles. bind:element use={[forwardEvents, [useActions, use]]} class={cx(className, getStyles({ css: override }))}
  • href={href ?? undefined} {...$$restProps}