Skip to content

Commit

Permalink
Increase maximum length for plain text attributes (#5339)
Browse files Browse the repository at this point in the history
* Increase maximum length for plain text attributes

* add changeset

* cleanup

---------

Co-authored-by: Wojciech Mista <[email protected]>
  • Loading branch information
2 people authored and poulch committed Jan 9, 2025
1 parent 184297b commit 47d93f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-worms-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Increased the maximum display length for `plainText` attribute to 10,000 characters.
8 changes: 5 additions & 3 deletions src/components/Attributes/AttributeRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ const AttributeRow: React.FC<AttributeRowProps> = ({
/>
);
case AttributeInputTypeEnum.PLAIN_TEXT: {
const MAX_LENGTH = 255;
const isTooLong = attribute.value[0]?.length > MAX_LENGTH;
// Since the API doesn't enforce a limit for plain text attribute length, we need to set one here. If we don't, the dashboard will freeze when the user tries to display a product with a long attribute value.
const MAX_LENGTH = 10000; // This is an arbitrary number. Dashboard will still work with a higher number, but it gets significantly slower.
const attributeValue = attribute.value[0];
const isTooLong = attributeValue?.length > MAX_LENGTH;

const value = getTruncatedTextValue(attribute.value[0], MAX_LENGTH);
const value = isTooLong ? getTruncatedTextValue(attributeValue, MAX_LENGTH) : attributeValue;

return (
<BasicAttributeRow
Expand Down

0 comments on commit 47d93f0

Please sign in to comment.