refactor: Fix dropdownComponent rendering issue and improve tableNodeCellRender value handling

This commit is contained in:
ogabrielluiz 2024-06-13 09:58:48 -03:00
commit 4527bce31e
3 changed files with 12 additions and 5 deletions

View file

@ -35,10 +35,9 @@ export default function Dropdown({
const PopoverContentDropdown =
children || editNode ? PopoverContent : PopoverContentWithoutPortal;
return (
<>
{Object.keys(options)?.length > 0 ? (
{Object.keys(options ?? [])?.length > 0 ? (
<>
<Popover open={open} onOpenChange={children ? () => {} : setOpen}>
{children ? (

View file

@ -131,7 +131,9 @@ export default function TableNodeCellRender({
<DictComponent
disabled={disabled}
editNode={true}
value={templateValue.toString() === "{}" ? {} : templateValue}
value={
(templateValue || "").toString() === "{}" ? {} : templateValue
}
onChange={(newValue) => {
handleOnNewValue(newValue, templateData.key);
}}

View file

@ -98,8 +98,14 @@ export default function GenericModal({
useEffect(() => {
setInputValue(value);
}, [value, modalOpen]);
const coloredContent = (inputValue || "")
?.toString()
let coloredContent = inputValue || "";
// Check if coloredContent is a string
// calling toString on undefined will throw an error
// so we need to check if it is a string first
if (typeof coloredContent !== "string") {
coloredContent = "";
}
coloredContent
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(regexHighlight, (match, p1, p2) => {