This is definitely a bug because the API allows specifying separate locations for each virtual disks and the virtual machine files.
If you connect directly to an ESXi (located at https://<server-hostname-or-ip>/ui) than you are using the ESXi Embedded Host Client. It is distributed as officially supported product and also as a Fling, which is VMware's apps developed by internal engineering teams but not officially supported. The good news is that you could report bugs on the VMware's flings portal at https://labs.vmware.com/flings/esxi-embedded-host-client#bugs
By the way I think this is a known issue reported by others. If you go to https://labs.vmware.com/flings/esxi-embedded-host-client#comments and search for I cannot add disk from a different datastore from where a VMis installed
you'll find issue similar to yours.
Considering the issue is fixed you could upgrade your client to the latest Fling. It is distributed as a VIB which you could install on your ESXi.