mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
ChannelPopover: cancel dismisses popover
This commit is contained in:
parent
1b1d7e9e80
commit
c92753d1ed
@ -90,8 +90,8 @@ export function FormGroupChild(props: { id: string }) {
|
||||
return <Box display="none" />;
|
||||
}
|
||||
|
||||
export function FormGroup(props: PropFunc<typeof Box>) {
|
||||
const { children, ...rest } = props;
|
||||
export function FormGroup(props: { onReset?: () => void; } & PropFunc<typeof Box>) {
|
||||
const { children, onReset, ...rest } = props;
|
||||
const [submits, setSubmits] = useState({} as { [id: string]: SubmitHandler });
|
||||
const [resets, setResets] = useState({} as Record<string, () => void>);
|
||||
const [dirty, setDirty] = useState({} as Record<string, boolean>);
|
||||
@ -102,7 +102,8 @@ export function FormGroup(props: PropFunc<typeof Box>) {
|
||||
|
||||
const resetAll = useCallback(() => {
|
||||
_.map(resets, (r) => r());
|
||||
}, [resets]);
|
||||
onReset && onReset();
|
||||
}, [resets, onReset]);
|
||||
|
||||
const submitAll = useCallback(async () => {
|
||||
await Promise.all(
|
||||
@ -160,7 +161,7 @@ export function FormGroup(props: PropFunc<typeof Box>) {
|
||||
borderTop="1"
|
||||
borderTopColor="washedGray"
|
||||
>
|
||||
<Button disabled={!isDirty} onClick={resetAll}>Cancel</Button>
|
||||
<Button onClick={resetAll}>Cancel</Button>
|
||||
<StatelessAsyncButton
|
||||
onClick={submitAll}
|
||||
disabled={hasErrors || !isDirty}
|
||||
|
@ -84,7 +84,7 @@ export function ChannelPopoverRoutes(props: ChannelPopoverRoutesProps) {
|
||||
isOwner={isOwner}
|
||||
baseUrl={props.baseUrl}
|
||||
/>
|
||||
<FormGroup height="100%" overflowY="auto" pt="5" flexGrow={1}>
|
||||
<FormGroup onReset={onDismiss} height="100%" overflowY="auto" pt="5" flexGrow={1}>
|
||||
<ChannelNotifications {...props} />
|
||||
{!isOwner && (
|
||||
<Col mx="4" mb="6" flexShrink={0}>
|
||||
|
Loading…
Reference in New Issue
Block a user