Skip to content

Commit

Permalink
Fix showing empty category input (#5090)
Browse files Browse the repository at this point in the history
* Fix showing empty category input

* Add changelog
  • Loading branch information
poulch authored and Cloud11PL committed Aug 5, 2024
1 parent d29c3f8 commit 508e53e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-ties-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Category input in product page is no longer collapsed when empty
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export const ProductOrganization: React.FC<ProductOrganizationProps> = props =>
errors,
);
const [categoryInputActive, setCategoryInputActive] = React.useState(false);

// Input is hide to proper handle showing nested category structure
const hideInput = !categoryInputActive && data.category && !disabled;

const noCategoryError =
formErrors.isPublished?.code === ProductErrorCode.PRODUCT_WITHOUT_CATEGORY
? formErrors.isPublished
Expand Down Expand Up @@ -161,12 +165,11 @@ export const ProductOrganization: React.FC<ProductOrganizationProps> = props =>
id: "ccXLVi",
defaultMessage: "Category",
})}
{...(!categoryInputActive &&
!disabled && {
width: "100%",
__opacity: 0,
position: "absolute",
})}
{...(hideInput && {
width: "100%",
__opacity: 0,
position: "absolute",
})}
onFocus={() => {
setCategoryInputActive(true);
}}
Expand Down

0 comments on commit 508e53e

Please sign in to comment.