This is formally known as a semi-gradient method.
What we would like to do is to minimize $\big(v(S) - \hat v(S, w)\big)^2$, where $v(S)$ is the true value function. This would give the gradient descent update
\begin{align*}
w \leftarrow w + \alpha[v(S) - \hat v(S, w)]\nabla \hat v(S, w) . \tag{1}
\end{align*}
Of course we don't have access to $v(S)$. So instead, we could use the monte carlo return (the observed, discounted, episodic return). The other option is to use a bootstraped estimate of $v(S)$, e.g. the estimate $r + \gamma \hat v(S', w)$, which would give the update
\begin{align*}
w \leftarrow w + \alpha[r + \gamma \hat v(S', w) - \hat v(S, w)]\nabla \hat v(S, w) \tag{2}
\end{align*}
As you correctly point out, Eq. 2 is no longer a true gradient descent method. To directly quote Sutton and Barto, section 9.3 page 165,
This step [Eq. 1] would not be valid if a bootstrapping estimate were
used in place of v(S). Bootstrapping methods are not in fact instances
of true gradient descent (Barnard, 1993). They take into account the
effect of changing the weight vector w on the estimate, but ignore its
effect on the target. They include only a part of the gradient and,
accordingly, we call them semi-gradient methods.
The 'estimate' here is refering to $\hat v(S, w)$, whereas the 'target' is $v(S)$ (or its approximation). Indeed the parameter update you give would be the true gradient descent update for minimizing $\big(r + \gamma \hat v(S', w) - \hat v(S, w)\big)^2$