Skip to content

Commit

Permalink
Merge pull request #18 from bleu-fi/remove-number-scroll
Browse files Browse the repository at this point in the history
Remove number scroll and add placeholder on CommandMenu
  • Loading branch information
luizakp authored Feb 8, 2024
2 parents bd8c1a4 + 03af3e1 commit 2ea0964
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/Cmdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
} from "@/components/ui";
import { cn } from "@/lib/utils";

export function CommandMenu({ commands, ...props }) {
export function CommandMenu({
commands,
placeholder = "Busca global",
...props
}) {
const navigate = useNavigate();
const [open, setOpen] = React.useState(false);

Expand Down Expand Up @@ -45,7 +49,7 @@ export function CommandMenu({ commands, ...props }) {
onClick={() => setOpen(true)}
{...props}
>
<span className="inline-flex">Busca global</span>
<span className="inline-flex">{placeholder}</span>
<kbd className="bg-muted top- pointer-events-none absolute right-1.5 hidden h-5 select-none items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex">
<span className="text-xs"></span>K
</kbd>
Expand Down
9 changes: 9 additions & 0 deletions src/components/FormBuilder/fields/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export const InputField = withConditional<InputFieldProps>(
.min(field.length?.minimum || 0)
.max(field.length?.maximum || Infinity);

const numberInputOnWheelPreventChange = (e) => {
e.target.blur();
e.stopPropagation();
};

return (
<FormField
control={form.control}
Expand All @@ -52,6 +57,10 @@ export const InputField = withConditional<InputFieldProps>(
placeholder={field.placeholder}
{...formField}
type={field.mode}
onWheel={(event) =>
field.mode === "number" &&
numberInputOnWheelPreventChange(event)
}
/>
</FormControl>
<FormMessage />
Expand Down
4 changes: 3 additions & 1 deletion src/components/FormBuilder/fields/RichTextEditorField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const RichTextEditorField = withConditional<RichTextEditorFieldProps>(
<FormDescription>{field.description}</FormDescription>
<input hidden {...formField} value={formField.value} />
<RichTextEditor
initialValue={formField.value}
initialValue={
typeof formField.value === "string" ? formField.value : ""
}
onChange={handleRichTextChange}
/>
<FormMessage />
Expand Down

0 comments on commit 2ea0964

Please sign in to comment.