Yes, there is a way to automatically disconnect mobile data when your Android device is connected to a Wi-Fi hotspot. However, you have to enable "developer options" in advance, and depending on the situation, there may be disadvantages.
Because developer options are disabled by default, you cannot operate the "Always turn on mobile data" switch. Open the "System" screen in the "Settings" app and tap the build number 7 or more times in a row. Now you can see "Developer options" in the advanced settings section of the "System" screen.
This "always on mobile data" switch isn't useful in every situation. For example, in places where there are multiple Wi-Fi access points with weak radio waves, such as around stations and restaurants, even if you can connect to Wi-Fi, it will be disconnected immediately, and mobile data communication will be turned off. , the Internet connection becomes unstable. If you want to use data communication reliably, it is better to turn on the "Always turn on mobile data" switch.