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

Fix asset selector onchange event #1868

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions .changeset/proud-ducks-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@penumbra-zone/ui': patch
---

Fix asset selector not firing onChange event
18 changes: 3 additions & 15 deletions packages/ui/src/Dialog/RadioItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyboardEventHandler, MouseEventHandler, ReactNode, useMemo } from 'react';
import { KeyboardEventHandler, ReactNode, useMemo } from 'react';
import { RadioGroupItem } from '@radix-ui/react-radio-group';
import { styled } from 'styled-components';
import { motion } from 'framer-motion';
Expand Down Expand Up @@ -103,16 +103,9 @@ export const RadioItem = ({
}
};

const onMouseDown: MouseEventHandler<HTMLButtonElement> = () => {
// close only after the value is selected by onClick
setTimeout(() => {
onClose?.();
}, 0);
};

// click is triggered by radix-ui on focus, click, arrow selection, etc. – basically always
const onClick = () => {
onSelect?.();
onClose?.();
};

const descriptionText = useMemo(() => {
Expand All @@ -133,12 +126,7 @@ export const RadioItem = ({

return (
<RadioGroupItem key={value} disabled={disabled} value={value} asChild>
<Root
{...asTransientProps({ actionType, disabled })}
onKeyDown={onEnter}
onMouseDown={onMouseDown}
onClick={onClick}
>
<Root {...asTransientProps({ actionType, disabled })} onKeyDown={onEnter} onClick={onClick}>
<Info>
{startAdornment}
<div>
Expand Down
Loading