[๐] Attribute re-render on spread in polymorphism does not work correctly
tzdesign opened this issue ยท 1 comments
tzdesign commented
Which component is affected?
Qwik Runtime
Describe the bug
Using polymorphism on button component
Reproduction
https://stackblitz.com/edit/qwik-starter-cahrue?file=src%2Froutes%2Findex.tsx
Steps to reproduce
No response
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@builder.io/qwik: ^1.4.3 => 1.4.3
@builder.io/qwik-city: ^1.4.3 => 1.4.3
typescript: 5.3.3 => 5.3.3
undici: 5.28.2 => 5.28.2
vite: 4.5.2 => 4.5.2
Additional Information
I am not sure if it's expected. But it works when I add a key from the outside through jsx or inside on top of rest:
export const Button = component$(
<C extends string | FunctionComponent>(props: ButtonProps<C>) => {
const {
variant = 'contained',
as: Comp = 'button' as C,
fullWidth,
loading,
...rest
} = props;
return (
<Comp
{...{
class: ['button', { fullWidth }, variant],
}}
onClick$={
'disabled' in rest && rest.disabled ? undefined : rest.onClick$
}
{...rest}
key={props.key}
>
{(loading === false || loading == null) && <Slot name="start" />}
<span class="label">
<Slot />
</span>
<Slot name="end" />
</Comp>
);
}
);
Note
This will be fixed in V2
wmertens commented
This is indeed a bug in the optimizer, but it's fixed in v2. Unfortunately the fix is very hard to backport, so we'll just have to wait for v2 (which will be minimally-to-not breaking).
As such I'll close this.