Skip to content

Commit

Permalink
Few minor fixes (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: Nik Nasr <[email protected]>
  • Loading branch information
nikrooz authored Jan 1, 2025
1 parent d389bee commit d8542b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion libs/features/restate-context/src/lib/RestateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ export function RestateContextProvider({
children,
adminBaseUrl,
ingressUrl,
isPending,
}: PropsWithChildren<{
adminBaseUrl?: string;
ingressUrl: string;
isPending?: boolean;
}>) {
return (
<AdminBaseURLProvider baseUrl={adminBaseUrl}>
<InternalRestateContextProvider ingressUrl={ingressUrl}>
<InternalRestateContextProvider
ingressUrl={ingressUrl}
isPending={isPending}
>
{children}
</InternalRestateContextProvider>
</AdminBaseURLProvider>
Expand Down
7 changes: 5 additions & 2 deletions libs/ui/button/src/lib/SubmitButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRef, type PropsWithChildren, useDeferredValue } from 'react';
import { useFetchers, useHref } from 'react-router';
import { useFetchers, useHref, useNavigation } from 'react-router';
import { Button } from './Button';
import { tv } from 'tailwind-variants';
import { useIsMutating } from '@tanstack/react-query';
Expand Down Expand Up @@ -45,8 +45,11 @@ function useIsSubmitting(action?: string) {
return formActionPathname === pathName;
},
});
const { state } = useNavigation();

return submitFetcher?.state === 'submitting' || isMutating > 0;
return (
submitFetcher?.state === 'submitting' || isMutating > 0 || state !== 'idle'
);
}

export function SubmitButton({
Expand Down
2 changes: 1 addition & 1 deletion libs/util/feature-flag/src/lib/type.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type FeatureFlag = 'FEATURE_OVERVIEW_PAGE';
export type FeatureFlag = 'FEATURE_OVERVIEW_PAGE' | 'FEATURE_INVOCATIONS_PAGE';
9 changes: 7 additions & 2 deletions libs/util/remix/src/lib/useFetcherWithErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ export function useFetcherWithError<
TData extends (
params: ClientActionFunctionArgs
) => Promise<{ errors?: Error[] } | any>
>({ key }: { key: string }) {
>({ key, method }: { key: string; method: string }) {
const fetcher = useFetcher<TData>({ key });
const [errors, setErrors] = useState<Error[]>();
const [canUpdateErrors, setCanUpdateErrors] = useState(true);

if (fetcher.state === 'submitting' && !canUpdateErrors) {
if (
fetcher.state === 'submitting' &&
!canUpdateErrors &&
fetcher.formAction === key &&
fetcher.formMethod === method
) {
setCanUpdateErrors(true);
}
if (fetcher.state === 'submitting' && errors) {
Expand Down

0 comments on commit d8542b6

Please sign in to comment.