
Correcting, in case anyone was confused:
The legacy of slavery did not go away, of course, and a major realignment _without_ party dissolution occurred after President Lyndon B. Johnson (Democrat, and from Texas) coaxed Congress to pass the Voting Rights Act of 1865, enacting long-overdue major protections of voting rights, and ^^^^ mostly having the effect of [re-]enfranchising black voters in the South.[2] According to legend, President Johnson said to observers when he signed the bill that it would cost the Democratic Party the South for a generation. If anything, he underestimated. Southern Democrats slowly trickled to the Republican Party after '65, and moved there en-masse under Ronald Reagan (1980s).
Er, 1965. A hypothetical USA with a (enforced) Voting Rights Act in 1865 would make an interesting bit of alternate history fiction. In _our_ timeline, FWIW, the victorious North that won the American Civil War in 1865, under the dominant Republican Party, enforced the rights of black voters diligently as part of 'Reconstruction', the gradual re-empowering of the rebellious southern states' governments, until the disputed presidential election of 1876, which once again deadlocked the Electoral College and threw the election to Congress. The deadlock was resolved by Congressional Republicans agreeing to end Reconstruction (and in return getting the 1876 Presidency), which basically betrayed southern black voters and condemned them to 70+ years of state and local laws enforcing racial segregation, and laws and extralegal politics intimidating or bureaucratically discouraging blacks from voting, the 'Jim Crow' era: https://en.wikipedia.org/wiki/Jim_Crow_laws Part of what ended 'Jim Crow' was mass migration of blacks out of the South to take industrial war-industries jobs elsewhere in the USA during WWII. But the rest of it took the Civil Rights Movement of the 1950s-1960s to expunge -- and of course it's not entirely done, either, e.g.: https://en.wikipedia.org/wiki/Jim_Crow_laws#New_Jim_Crow