iway1 / trpc-panel

MIT License
627 stars 43 forks source link

Optional fields should rather default to undefined than null #30

Closed torgesla closed 1 year ago

torgesla commented 1 year ago

As of version 1.2.3 of tRPC-panel, empty input fields default to null. Should these rather default to undefined to match with Zod's default value for optional parameters? When a request like this is executed:

image

the payload ends up like this:

{"0":{
    "json":{
      "name":null,
      "ids":[],
      "siteId":null
    },
    "meta":{
        "values":{
          "name":["undefined"],
          "siteId":["undefined"]
          }
       }
   }
}

instead of this:

{"0":{
    "json":{
      "name":undefined,
      "ids":[],
      "siteId":undefined
    },
    "meta":{
        "values":{
          "name":["undefined"],
          "siteId":["undefined"]
          }
       }
   }
}
iway1 commented 1 year ago

Yeah they should to default to undefined for sure - looking at the code they should be defaulting to undefined at the moment and I'm not able to reproduce (I'm seeing undefined when for optional text fields in both the form values and what gets passed to the query).

If you could send the schema you're using that leads to this behavior and also let me know where you're logging so I can investigate?

iway1 commented 1 year ago

Going to close because of no activity / reproduction. Feel free to reopen with reproduction