# Continuity of bijection with continuous factor, continuous on each fiber, and each fiber connected.

Suppose $X$ , $Y$ , and $Z$ are compact metric spaces. Suppose $g: Y\to Z$ is a continuous surjection and each fiber $g^{-1}(z)$ is connected.

Suppose $f:X\to Y$ is a bijection such that $g\circ f:X \to Z$ is continuous and the restriction of $f$ to $f^{-1}g^{-1}(z)$ is continuous for all $z\in Z$.

Does it follow that $f$ is continuous?

As answered by Adayah here: Bijection with continuous factors continuous on each fiber.,

the answer is "no" without the connectedness assumption on the fibers.

Inspired by Adayah's answer, we can find a function $f$ that is not continuous.
Let $X=Y=[0,1]\times[0,1]$, and $Z=[0,1]$. Define $f$ and $g$ by $$f(x,y)=\begin{cases} (x,y)\quad y<1/2 \\ (1-x,y)\quad y\ge1/2 \end{cases}$$ $$g(x,y)=y$$
Then $f$ is a bijection and $g$ is a continuous surjection, and $g\circ f$ is continuous since $(g\circ f)(x,y)=y$. The preimage of some $z\in Z$ under $f\circ g$ is the connected set $[0,1]\times \{z\}$, which $f$ acts on either as the identity if $z<1/2$ or by negating the first argument if $z\ge1/2$.