Skip to content

Commit ce7fe44

Browse files
Merge pull request #772 from thejackshelton/fix-input
fix: input and bind:value
2 parents eee4557 + 43e3ae7 commit ce7fe44

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.changeset/fast-actors-report.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export default component$(() => {
105105

106106
- Programmatically toggling the popover is still possible, make sure to put the same id on the `<Popover.Root />` that is passed to the `usePopover` hook. Refer to the docs for more info.
107107

108+
- popover-showing and popover-closing classes have been deprecated. Please use the `data-open` and ``data-closing` attributes instead.
109+
110+
- The `data-open`, `data-closing`, and `data-closed` data attributes have been added to the popover.
111+
108112
#### <Popover.Root />
109113

110114
There is a new root compomnent. Configurable props have been moved to the root component.

apps/website/src/routes/docs/styled/input/examples/hero.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ import { component$ } from '@builder.io/qwik';
22
import { Input } from '~/components/ui';
33

44
export default component$(() => {
5-
return <Input type="email" placeholder="Email" />;
5+
return (
6+
<>
7+
<Input type="email" placeholder="Email" value="[email protected]" />
8+
</>
9+
);
610
});

packages/kit-styled/src/components/input/input.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { component$, type PropsOf } from '@builder.io/qwik';
1+
import { component$, useSignal, type PropsOf } from '@builder.io/qwik';
22
import { cn } from '@qwik-ui/utils';
33

44
type InputProps = PropsOf<'input'> & {
@@ -10,19 +10,26 @@ export const Input = component$<InputProps>(
1010
name,
1111
error,
1212
'bind:value': valueSig,
13+
value,
1314
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1415
'bind:checked': checkedSig,
1516
id,
1617
...props
1718
}) => {
1819
const inputId = id || name;
20+
const inputRef = useSignal<HTMLInputElement>();
21+
22+
// TODO: remove this when we can figure out why the optimizer forces you to have a signal rather than conditionally adding the bind:value prop.
23+
const dummySig = useSignal<string | undefined>(value?.toString());
24+
1925
return (
2026
<>
2127
<input
2228
{...props}
2329
aria-errormessage={`${inputId}-error`}
2430
aria-invalid={!!error}
25-
bind:value={valueSig}
31+
bind:value={valueSig ? valueSig : dummySig}
32+
ref={inputRef}
2633
class={cn(
2734
'flex h-12 w-full rounded-base border border-input bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
2835
props.class,

0 commit comments

Comments
 (0)