Door latches come in many designs and are a common problem. The most common is a floppy handle on many Whirlpool models. The pivot point on the plastic handle snaps off and the handle feels loose and only opens when you play with it. But Whirlpool is not alone, many brands have similar issues. Fortunately these repairs are pretty obvious once the door is opened up and inspected. That design is shown here:
Exercise caution! Many times a quickly diagnosed latch is really an obstruction to closing of the door. The most common is a loose upper mounting screw, rubbing the door.
Plates or silverware can block a rack from closing all the way and seem like a bad latch. Look very carefully. I once had a plumber cut a 2x4 to size and jam it between the cabinet fronts, across the aisle, to force the dishwasher door closed. It made the kitchen a little hard to navigate in. The customer was convinced she needed a new latch. I found a hidden spoon holding the door open barely 1/2". Just enough to cause a problem. I wonder what kind of a plumber the guy was? I don't think I've gotten back to that house; perhaps they were too embarrased.
Latches usually include micro switches that confirm that the door is closed. A bad switch is a common problem.