Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove number scroll and add placeholder on CommandMenu #18

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<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