Let $G$ be a compact connected Lie group with Lie algebra $\mathfrak{g}$. Then, $\mathfrak{g}=Z_{\mathfrak{g}}\oplus[\mathfrak{g},\mathfrak{g}]$ where $Z_{\mathfrak{g}}$ is the center of $\mathfrak{g}$ and $[\mathfrak{g},\mathfrak{g}]$ is semisimple. Let $Z^0_G$ be the identity component of the center $Z_G$ of $G$ and let $G_{ss}$ be the unique connected subgroup of $G$ with Lie algebra $[\mathfrak{g},\mathfrak{g}]$.

Question.Is $G$ always isomorphic to the direct product $Z_G^0\times G_{ss}$?

Clearly, $Z_G^0\times G_{ss}$ is a Lie group with Lie algebra $\mathfrak{g}$. Moreover, according to Knapp's *Lie groups beyond an introduction* (Theorem 4.29), $G_{ss}$ and $Z_G^0$ are closed subgroups of $G$, and $G$ is the commuting product $G=Z_G^0G_{ss}$. Hence, the product map
$$\varphi:Z_G^0\times G_{ss}\to G$$
is a surjective Lie group homomorphism. Moreover, $G_{ss}\cap Z_G^0$ is a connected closed subgroup with Lie algebra $[\mathfrak{g},\mathfrak{g}]\cap Z_{\mathfrak{g}}=\{0\}$. So $G_{ss}\cap Z_G^0$ is finite and connected, hence trivial. Therefore $\varphi$ is injective and hence an isomorphism. Is this argument correct?