2012 Hyundai Elantra - Dome light stays on

why does the dome light come on and stay on while driving.

There are a couple of possibilities. First, check to make sure the switch on the dome light isn’t in the “On” position. Next, there could be a problem with one of the door switches. Find each switch with the door open and press it. Do this with all four doors. If the light doesn’t go out for one particular door you’ve found the problem. If none of the switches is definitely the culprit there could be a short somewhere. A good mechanic can find out where. Or you may even have a bad body control module. It’s what controls the delay so that the dome light doesn’t go out right away when you close the doors.