State legislators are grappling with a persistent problem in which children in mental health crises are held in emergency departments for days or weeks without meaningful treatment plans, straining both families and the healthcare system.