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 = const PopoverContentDropdown =
children || editNode ? PopoverContent : PopoverContentWithoutPortal; children || editNode ? PopoverContent : PopoverContentWithoutPortal;
return ( return (
<> <>
{Object.keys(options)?.length > 0 ? ( {Object.keys(options ?? [])?.length > 0 ? (
<> <>
<Popover open={open} onOpenChange={children ? () => {} : setOpen}> <Popover open={open} onOpenChange={children ? () => {} : setOpen}>
{children ? ( {children ? (

View file

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

View file

@ -98,8 +98,14 @@ export default function GenericModal({
useEffect(() => { useEffect(() => {
setInputValue(value); setInputValue(value);
}, [value, modalOpen]); }, [value, modalOpen]);
const coloredContent = (inputValue || "") let coloredContent = inputValue || "";
?.toString() // 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, "&lt;")
.replace(/>/g, "&gt;") .replace(/>/g, "&gt;")
.replace(regexHighlight, (match, p1, p2) => { .replace(regexHighlight, (match, p1, p2) => {