Humans are naturally very tribal. I feel like most liberals either don't realize this, or refuse to believe it, and it really impairs their messaging when trying to win elections.
I've been listening to and reading a lot of research recently that indicates that ANY PERCEPTION that your tribe is losing numbers and/or status relative to other tribes causes people to become more conservative in political views and in voting. This includes members of statistically minority 'tribes' who perceive themselves as losing status relative to their previous status. Interestingly, the shift to align with conservative positions apparently includes a shift to be more conservative on policies not even related to immigration and demographics (e.g., on environmental issues, military spending, etc.).
This perception of status change that drives the ideological shift often has almost nothing to do with ACTUAL numbers of each 'tribe', nor the day to day conditions the anxious tribe is experiencing. They might be secure economically, with decent jobs (most white Trump voters were). They might not even be living in towns or states that are experiencing much growth in minority populations (also true of most Trump voters).
I grew up in a small, 99% white, mostly protestant, Midwestern town that voted for Trump, and I have seen this is action. When I was a kid you could literally count racial minority families on one hand (mostly Native American). There was one Jewish family. LGBT people were all closeted. At this time, b/c most of the residents were white, tribalism and prejudice appeared along other lines: non protestants were suspect...Catholics in particular were considered to be the 'rednecks' of the town. The town divided tribally between working and professional classes (education and financial status). My family was professional class and there was a lot of angst among the older generation on how to keep the town from becoming 'trashy' (i.e., how to increase the number and power of professional class, educated, conservative voting protestants) and how to discourage leftist 'hippies' (whites with non conforming clothes/grooming/jewelry/long hair or facial hair) from cluttering up the town during the tourist season. The 'power elite' (LOL) never worried about discouraging racial minorities b/c they weren't even on anyone's radar.
When I go back now, I might see a dozen minority-race people during a couple rounds of the downtown. There are a few yoga studios (:gasp: HIPPIES!!!) and a Whole Foods knockoff (MORE HIPPIES). I saw a gay couple (men) holding hands in the street. Now, objectively speaking, this is an obvious indicator that there has been a large increase in the relative number, and somewhat of an increase in relative percent, of minorities (or at least visible minorities) since my childhood. But in reality, the town is still 95% white (according to Wikipedia, anyway) and probably still mostly Protestant.
However, the reality of numbers is not very related to how most people emotionally process just seeing/casual exposure to more minorities and/or diversity in their environment. For example, I was listening to a discussion of survey data about changing U.S. demographics. Currently, MOST white Americans believe that the U.S. is already a majority minority country even though it is not expected to be that for another ~20 years. Further, e.g., white Ohioans believe that they are CURRENTLY the minority in Ohio, and they have believed this for some years, DESPITE the fact that whites actually comprise ~82% of the population!!
Perception is reality when it comes to voting, and the Dems have a staggeringly stupid habit of tending to message their campaigns in ways that draw further attention to diversity, and to the grievances of sub-groups and special interests within their coalition, which naturally feeds into tribalistic instincts in voters, even some voters who might otherwise be receptive to their economic messaging.
Unless Dems figure out a way around this problem, I think we're going to see the GOP party of white anxiety hang on a lot longer than demographic shifts indicate they could or should.