Lots of posts on this issue if you do a search. Can't help thinking your flooding problem is related to this, given your thread of the leaking sunroof..... has it been opening and closing normally up to now, without leaking, until the flood you described? As someone else said, it sounds like a misalignment or a seal problem - have you solved the leak problem yet? Methinks your problems won't be solved until the leak issue is addressed.
You may also have a problem with the sunroof motor - perhaps it was closed manually while your car was in for repair as you said, and have not been properly re-engaged with the motor. You need to do this manually - the procedure is in the manual.