Hi, my name is ***** ***** I have been in the home improvement and repair field for 20 years. I will be very glad to help you today. If the compartment has much soap residue or the close mechanism does not open easily it may be the cause of the issue. Also if the rinse aid cap is not fitted properly that will also cause the soap compartment door to not open when it should. Check that the rinse aid cap is fitted and not warped.
Also check that the spring and close latch on the soap door is not bent at the end of the spring.
Some newer dishwashers have a more advanced mechanism that is opened by a part called a wax motor. The wax motor may have failed and need to be replaced. Older models would have a bi-metal release also operated by electricity. These can both be checked with a multi-meter for continuity.
Some dishwasher soap doors are operated by a timer also.
You would want to find in your manual a wiring schematic to determine what device is operating the soap door.
One of these would be the issue. Hopefully it ends up being just the rinse aid cap since that would be the easiest!