Appropriate family with connected fibers on a connected schema

I was reading Q. Liu's handbook and there is an exercise:

Let $ f: X rightarrow Y $ to be a surjective morphism. We suppose that $ Y $ is connected
and that all the fibers $ X_y $ is connected. Show that if $ X $ is correct on $ Y $ then $ X $ is connected.

I have some ideas but not a complete proof. If we have an arbitrary ringed space $ (X, O_X) $ and there are no non-trivial idempotents in $ O_X (X) $, then the space is connected. Then the Stacks 09V4 project tag implies that if we have a proper morphism $ f: X rightarrow Y $then $ (f_ * O_X) _y = O_X (f ^ {- 1} (y)) $ for any point $ y in Y $. This combination with fiber connectivity implies that $ (f_ * O_X) _y $ does not contain any non-trivial idempotent for any $ y in Y $. I probably should somehow use the direct definition of the stem but I do not see how.