Skip to content

Replace custom Select component with native select in webhook filter UI #7213

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { useThirdwebClient } from "@/constants/thirdweb.client";
import { useQueryClient } from "@tanstack/react-query";
Expand Down Expand Up @@ -305,97 +298,46 @@ export function FilterDetailsStep({
{watchFilterType === "event" &&
Object.keys(fetchedAbis).length > 0 &&
eventSignatures.length > 0 ? (
<Select
<select
Copy link
Member

Choose a reason for hiding this comment

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

what's wrong with the shadcn components? we should really be re-using our building blocks here. if there's something not working, we fix the building block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't scroll in prod. everything works in localhost but it breaks in prod. https://thirdwebdev.slack.com/archives/C085FEPFLN9/p1748542970097279

Copy link
Member

Choose a reason for hiding this comment

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

so we fix the component - can't go backwards. we're trying to use a common set of components everywhere. otherwise its chaos

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, Im not the best person to fix such things 😅 I'll give it another try in my morning. until then the dropdown is broken in prod, if somebody complains assign the ticket to me

className="h-10 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"
value={field.value}
onValueChange={(value) => {
field.onChange(value);
// Find the selected event
onChange={(e) => {
field.onChange(e.target.value);
const selectedEvent = eventSignatures.find(
(sig) => sig.signature === value,
(sig) => sig.signature === e.target.value,
);
// Set the ABI for the event
form.setValue("sigHashAbi", selectedEvent?.abi || "");
}}
>
<SelectTrigger>
<SelectValue placeholder="Select an event signature">
{field.value
? eventSignatures.find(
(sig) => sig.signature === field.value,
)?.name || ""
: null}
</SelectValue>
</SelectTrigger>
<SelectContent className="max-h-60 overflow-y-auto">
{eventSignatures.map((event) => {
// Truncate the hash for display purposes
const truncatedHash = truncateMiddle(
event.signature,
6,
4,
);

return (
<SelectItem
key={event.signature}
value={event.signature}
title={event.name}
>
<div className="flex flex-col">
<span className="font-medium">{event.name}</span>
<span className="text-muted-foreground text-xs">
Signature: {truncatedHash}
</span>
</div>
</SelectItem>
);
})}
</SelectContent>
</Select>
<option value="">Select an event signature</option>
{eventSignatures.map((event) => (
<option key={event.signature} value={event.signature}>
{event.name} (Signature:{" "}
{truncateMiddle(event.signature, 6, 4)})
</option>
))}
</select>
) : watchFilterType === "transaction" &&
Object.keys(fetchedTxAbis).length > 0 &&
functionSignatures.length > 0 ? (
<Select
<select
className="h-10 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"
value={field.value}
onValueChange={(value) => {
field.onChange(value);
// Find the selected function
onChange={(e) => {
field.onChange(e.target.value);
const selectedFunction = functionSignatures.find(
(sig) => sig.signature === value,
(sig) => sig.signature === e.target.value,
);
// Set the ABI for the function
form.setValue("sigHashAbi", selectedFunction?.abi || "");
}}
>
<SelectTrigger className="max-w-full">
<SelectValue placeholder="Select a function signature">
{field.value
? functionSignatures.find(
(sig) => sig.signature === field.value,
)?.name || ""
: null}
</SelectValue>
</SelectTrigger>
<SelectContent className="max-h-60 max-w-[600px] overflow-y-auto">
{functionSignatures.map((func) => (
<SelectItem
key={func.signature}
value={func.signature}
title={func.signature}
className="w-full overflow-x-auto"
>
<div className="flex w-full flex-col">
<span className="overflow-x-auto whitespace-nowrap pb-1 font-medium">
{func.name}
</span>
<span className="overflow-x-auto text-muted-foreground text-xs">
Selector: {func.signature}
</span>
</div>
</SelectItem>
))}
</SelectContent>
</Select>
<option value="">Select a function signature</option>
{functionSignatures.map((func) => (
<option key={func.signature} value={func.signature}>
{func.name} (Selector: {func.signature})
</option>
))}
</select>
) : (
<Input
placeholder={
Expand Down
Loading