Is California state tax filing for capital gain earned while living in Washington state mandatory?

I lived in California for 6 months (1/1/21-5/31/21) and moved to Washington state on 6/1/21. During the time I lived in CA, I did not work and chose not to apply for any unemployment assistance. Basically, I had no W2 income from employment. However, I do have an investment account managed by a financial advisor at a bank. My permanent residence is in WA since June and now I want to sell some of my stocks. I understand this capital gain will be taxed for the federal return since WA state does not have state tax like CA. Would the state of California tax this capital gain too even if the capital gain was made after I moved to different state? I don't know if they can tell if the capital gain was earned at what time of the year to tax accordingly. I will still have to file for CA state tax and federal tax in 2021 since the first half of this year I resided in CA. Thank you for your opinions.