refactor: Fix dropdownComponent rendering issue and improve tableNodeCellRender value handling
This commit is contained in:
parent
d9eb22b3ab
commit
4527bce31e
3 changed files with 12 additions and 5 deletions
|
|
@ -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 ? (
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -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, "<")
|
.replace(/</g, "<")
|
||||||
.replace(/>/g, ">")
|
.replace(/>/g, ">")
|
||||||
.replace(regexHighlight, (match, p1, p2) => {
|
.replace(regexHighlight, (match, p1, p2) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue