update modal list when necessary

This should fix the problem about modals not being hidden correctly when allowMultiple is false. The modal list is updated when needed.

I don't know much about semantic's code philosophy, so I don't know if I coded it the right way. However that does the job. At worse I hope it will help someone to fix it properly :)