The simple fact that a parent attempted suicide won't necessarily guarantee that he/she has no chance at all of retaining custody of children if the non-custodial parent attempts to modify the order to gain primary custody.
The first thing that will happen, before the suicide affects the case, is that the reasons for the suicide will be analyzed and the mental/emotional stability of the parent will be assessed.
It is possible, if the parent is otherwise stable and has reasonably proven that this was a singular lapse in judgment, one of those moments where the world barrels in on you, that the suicide attempt might not strike a huge blow to the ability of that parent to retain custody. This would depend heavily on the courts belief that this was a completely isolated incident and the likelihood of it happening again is slim-to-none.
Now, even in this best case scenario this attempt will still hinder the ability of this parent to keep custody. Even a singular lapse in control like that is a serious lapse and would have to be taken into account.
Now, if the parent is judged stable and the courts rule this is a singular incident they will still weigh in all the other factors in deciding the best custodial arrangement for the child.
If, despite the attempt, this parent is considered to still be the most responsible and stable location for the child (probably due to heavy instability in the life of the other parent) custody may not be altered simply because of this one incident.
This would definitely seem to at least give grounds for a custody hearing though if the non-custodial parent were to request it. The courts will want to decide whether this home remains a stable place and the custodial parent remains mentally/emotionally able to raise the child properly.
It is possible that the courts will decide that the custody arrangement is still in the best interest of the child
though. The attempt doesn't necessarily doom the parent to losing custody unless the specific circumstances/details make the parent an unstable influence to be a custodial parent.