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(cancel-button): update cancel button behavior on asset edit page #1572

Merged
merged 2 commits into from
Jan 14, 2025
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
18 changes: 14 additions & 4 deletions app/components/assets/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const AssetForm = ({
encType="multipart/form-data"
>
<AbsolutePositionedHeaderActions className="hidden md:flex">
<Actions disabled={disabled} />
<Actions assetId={id} disabled={disabled} />
</AbsolutePositionedHeaderActions>
{qrId ? (
<input type="hidden" name={zo.fields.qrId()} value={qrId} />
Expand All @@ -157,7 +157,7 @@ export const AssetForm = ({
<p>Basic information about your asset.</p>
</div>
<div className="hidden flex-1 justify-end gap-2 md:flex">
<Actions disabled={disabled} />
<Actions assetId={id} disabled={disabled} />
</div>
</div>

Expand Down Expand Up @@ -420,10 +420,20 @@ export const AssetForm = ({
);
};

const Actions = ({ disabled }: { disabled: boolean }) => (
const Actions = ({
assetId,
disabled,
}: {
assetId?: string;
disabled: boolean;
}) => (
<>
<ButtonGroup>
<Button to=".." variant="secondary" disabled={disabled}>
<Button
to={assetId ? `/assets/${assetId}/overview` : ".."}
variant="secondary"
disabled={disabled}
>
Cancel
</Button>
<AddAnother disabled={disabled} />
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_layout+/assets.$assetId_.edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default function AssetEditPage() {
);

return (
<>
<div className="relative">
<Header title={hasTitle ? title : asset.title} />
<div className=" items-top flex justify-between">
<AssetForm
Expand All @@ -242,6 +242,6 @@ export default function AssetEditPage() {
tags={tags}
/>
</div>
</>
</div>
);
}
5 changes: 3 additions & 2 deletions app/routes/_layout+/assets.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,13 @@ export default function NewAssetPage() {

// Get category from URL params or use the default passed prop
const categoryFromUrl = searchParams.get("category");

return (
<>
<div className="relative">
<Header title={title ? title : "Untitled Asset"} />
<div>
<AssetForm qrId={qrId} category={categoryFromUrl || undefined} />
</div>
</>
</div>
);
}
Loading