Skip to content

Commit

Permalink
fix: zero filling size list
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Nov 27, 2023
1 parent f691630 commit d44f519
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions src/component/elements/Select.tsx
Expand Up @@ -95,20 +95,36 @@ const Select = forwardRef(function Select(
)}

{items.map((option) => {
if (
typeof option[itemValueField] !== 'string' ||
typeof option[itemTextField] !== 'string'
) {
// TODO: throw error
const value = option[itemValueField];

if (!['number', 'string'].includes(typeof option[itemTextField])) {
// eslint-disable-next-line no-console
console.log(
`The '${itemTextField}' field should be a string , option : ${JSON.stringify(
option,
)}`,
);
return null;
}
if (!['number', 'string'].includes(typeof value)) {
// eslint-disable-next-line no-console
console.log(
`The '${itemValueField}' field should be either a string or a number, option : ${JSON.stringify(
option,
)}`,
);
return null;
}

const label = String(option[itemTextField]);

return (
<option
key={JSON.stringify(option)}
value={option[itemValueField]}
value={value}
data-value={JSON.stringify(option)}
>
{textRender?.(option[itemTextField]) || option[itemTextField]}
{textRender?.(label) || label}
</option>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion src/data/utilities/generateNumbersPowerOfX.ts
Expand Up @@ -21,6 +21,6 @@ function formatNumber(number: number): string | number {
} else if (number >= 1024) {
return `${number / 1024}K`;
} else {
return number;
return `${number}`;
}
}

0 comments on commit d44f519

Please sign in to comment.