Skip to content

Commit

Permalink
fix(pathname): hide Preview button when outside of Presentation tool …
Browse files Browse the repository at this point in the history
…(eg. in Structure tool) (#68)

* fix(pathname): hide Preview button when outside of Presentation tool (eg. in Structure tool)

* chore: changeset
  • Loading branch information
marcusforsberg authored Jun 11, 2024
1 parent 3702ee5 commit 2a263d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-phones-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tinloof/sanity-studio": patch
---

Hide the "Preview" button from the `pathname` field when used in the Structure Tool (where it has no effect).
30 changes: 15 additions & 15 deletions packages/sanity-studio/src/components/PathnameFieldComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,21 +423,21 @@ function PreviewButton({ localizedPathname }: { localizedPathname: string }) {
}, [navigate, localizedPathname]);

return (
<Button
text="Preview"
fontSize={1}
height={"100%"}
mode="default"
tone="default"
icon={EyeOpenIcon}
disabled={
!navigate ||
typeof localizedPathname !== "string" ||
preview === localizedPathname
}
title="Preview page"
onClick={handleClick}
/>
!!navigate && (
<Button
text="Preview"
fontSize={1}
height={"100%"}
mode="default"
tone="default"
icon={EyeOpenIcon}
disabled={
typeof localizedPathname !== "string" || preview === localizedPathname
}
title="Preview page"
onClick={handleClick}
/>
)
);
}

Expand Down

0 comments on commit 2a263d7

Please sign in to comment.