langflow 创建数据和更新数据组件中数值输入的前导零问题

wztqucjr  于 6个月前  发布在  其他
关注(0)|答案(1)|浏览(60)

Describe the bug

While utilizing the Create Data and Update Data components for data encapsulation, I have encountered an issue where numeric values that begin with a zero are automatically stripped of their leading zeros. For instance, the number ' 029 ' is incorrectly transformed into ' 29 '. This behavior is problematic as it can lead to data inconsistency and errors in applications that rely on the preservation of leading zeros for significance or formatting purposes.

Browser and Version

  • Edge, Chrome
  • Version: 1.0.7 - 1.0.9
jjjwad0x

jjjwad0x1#

要解决Create DataUpdate Data组件中数值被去除前导零的问题,你需要确保这些值被视为字符串而非数字。这可以通过修改onChange处理器来实现,使其将输入处理为字符串。
以下是如何修改onChange处理器以使InputComponent的值被视为字符串的示例:

<Case
  condition={
    !node.data.node.template[templateField].multiline &&
    !node.data.node.template[templateField].list
  }
>
  <InputComponent
    editNode={true}
    disabled={false}
    password={node.data.node.template[templateField].password ?? false}
    value={
      !node.data.node.template[templateField].value ||
      node.data.node.template[templateField].value === ""
        ? ""
        : node.data.node.template[templateField].value
    }
    onChange={(target) => {
      setData((old) => {
        let newInputList = cloneDeep(old);
        newInputList![i].data.node.template[templateField].value = target; // Ensure value is treated as string
        return newInputList;
      });
    }}
  />
</Case>

通过确保value被视为字符串,你可以防止前导零被去除。这种方法应该应用于所有可能输入数值的相关输入组件。

  • 要继续与1(https://github.com/langflow-ai/langflow/blob/dev/src/frontend/src/components/codeTabsComponent/index.tsx)交流,请提及@dosu。*

相关问题