>>17782392 (OP)Over the course of 20th century, and the tail end of the 19th, the Democrats built a strong liberal wing in the northern cities, particularly amongst immigrants and union workers.
This contingent of the party was not racist, and they also became more and more powerful over time. Alienating the south.
Meanwhile the Republicans began to drop racial equality from their rhetoric and agenda in no small part to win elections in the south.
Over the course of decades this meant that slowly more white southerners were voting for the GOP, and black people abandoned the GOP for the Democrats.
This was a slow process, the old Southern wing of the Democrats wasn't fully phased out until the 2000s.