data-driven-forms / react-forms

React library for rendering forms.
https://data-driven-forms.org/
Apache License 2.0
302 stars 87 forks source link

Condition isNot Empty does not work with MUI calendars. #1478

Closed adityapatil9191 closed 2 months ago

adityapatil9191 commented 3 months ago

Scope: <DESCRIBE SCOPE OF THIS ISSUE, i.e.: PF4 mapper, Form renderer> I have a react component which needs to be conditionally shown only if Date picker has a valid value select. I am using condition : {when:"field-1", isNotEmpty:true} .

Description Please find the sandbox example for reference. const schema = { title: "IsNotEmpty condition", fields: [ { component: componentTypes.DATE_PICKER, name: "field-1", label: "Field 1", helperText: "To show field 2 write anything here!" }, { component: componentTypes.TEXT_FIELD, name: "field-2", label: "Field 2", initialValue: "I am shown!", isDisabled: true, condition: { when: "field-1", isNotEmpty: true } } ] };

Schema

import React from "react"; import FormRenderer from "@data-driven-forms/react-form-renderer/form-renderer"; import componentTypes from "@data-driven-forms/react-form-renderer/component-types"; import DatePicker from "@data-driven-forms/mui-component-mapper/date-picker"; import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; import TextField from "@data-driven-forms/mui-component-mapper/text-field"; import FormTemplate from "@data-driven-forms/mui-component-mapper/form-template"; import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";

const schema = { title: "IsNotEmpty condition", fields: [ { component: componentTypes.DATE_PICKER, name: "field-1", label: "Field 1", helperText: "To show field 2 write anything here!" }, { component: componentTypes.TEXT_FIELD, name: "field-2", label: "Field 2", initialValue: "I am shown!", isDisabled: true, condition: { when: "field-1", isNotEmpty: true } } ] };

const componentMapper = {

};

const IsNotEmpty = () => (

); IsNotEmpty.displayName = "Is not empty";

export default IsNotEmpty;

https://codesandbox.io/s/data-driven-forms-example-forked-z244xk?file=/src/App.js:0-1473

Hyperkid123 commented 2 months ago

The sandbox link is not working. Can you share a new link?

adityapatil9191 commented 2 months ago

@Hyperkid123 please try this link https://codesandbox.io/p/sandbox/data-driven-forms-example-forked-z244xk?file=%2Fsrc%2FApp.js%3A0-1473&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clz6von2b00073b6n6nrwvwtm%2522%252C%2522sizes%2522%253A%255B100%252C0%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clz6von2b00033b6nuk4f4fu2%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clz6von2b00043b6nkllrj4lj%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clz6von2b00063b6nqkz2xoxf%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clz6von2b00033b6nuk4f4fu2%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clz6von2b00023b6ngm96v5ad%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A0%252C%2522endLineNumber%2522%253A1473%257D%255D%252C%2522filepath%2522%253A%2522%252Fsrc%252FApp.js%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clz6von2b00033b6nuk4f4fu2%2522%252C%2522activeTabId%2522%253A%2522clz6von2b00023b6ngm96v5ad%2522%257D%252C%2522clz6von2b00063b6nqkz2xoxf%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clz6von2b00053b6nx3h3xqwo%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522clz6von2b00063b6nqkz2xoxf%2522%252C%2522activeTabId%2522%253A%2522clz6von2b00053b6nx3h3xqwo%2522%257D%252C%2522clz6von2b00043b6nkllrj4lj%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522clz6von2b00043b6nkllrj4lj%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Afalse%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Hyperkid123 commented 2 months ago

Thanks. I am looking now.

I think this might be the problem:

warning.js:19 MUI X: The `renderInput` prop has been removed in version 6.0 of the Date and Time Pickers.
You can replace it with the `textField` component slot in most cases.
For more information, please have a look at the migration guide (https://mui.com/x/migration/migration-pickers-v5/#input-renderer-required-in-v5).
Hyperkid123 commented 2 months ago

OK I found the issue. Date is a bit special and needs a different approach. I'll post a PR soon.

rvsia commented 2 months ago

:tada: This issue has been resolved in version 3.23.3 :tada:

The release is available on

Data-Driven-Forms.org!