Fierce rhetoric on immigration was the fuel on which much of Donald Trump's presidential campaign ran. His promises to take a hard line on enforcement resonated with millions of American voters, who responded enthusiastically and flocked to his rallies. It should come as no surprise, then, that as president, he is turning his tough-on-immigration talk into action.

But that doesn't mean doing so is good for him.

Indeed, President Trump's latest thoughtless action and comments on immigration threaten to crush Republican momentum in the midterm elections. To wit:

“Somehow I don’t think that putting kids in cages is likely to go over very well with suburban moms.”~Whit Ayres, GOP pollster

Of course, the issue is that several weeks ago, under pressure from President Trump, the Departments of Homeland Security and Justice instituted a zero-tolerance policy for illegal entries into the country. All those caught faced detention and prosecution, including those who crossed the border with children. This fulfilled Trump's campaign pledge to enforce the law at the border, even for the misdemeanor charge of illegal entry, and to end what is commonly called a "catch and release" process that all but ensures that illegal entrants will escape prosecution. This matters because while the first violation only constitutes a misdemeanor, any subsequent illegal entries after a conviction are felonies. To ensure that repeat offenders face starker consequences, the U.S. has to have prosecuted the misdemeanor first.

That, however, set in motion a series of consequences that could have been easily foreseen — and in fact were. The detention of adults for prosecution as illegal immigrants required them to be separated from children apprehended by Customs and Border Patrol, who by law and by earlier Supreme Court decisions cannot be detained in facilities intended for adults. Much like children left without guardians by arrests by police departments across the U.S., these children become wards of the government and are either placed with other family members, foster homes, or temporary shelters until their parents are free to care for them again.

Now, this sort of separation of children from their parents has been happening for some time. The Washington Post reported years ago about the so-called Juvenile Referral Process and the hundreds of minors caught up in the system — as a "punishment" for crossing the border, often repeatedly. But neither the Bush or Obama administration did this on anything close to the same scale as the Trump administration has in the last several weeks.

Perhaps those precedents are why the White House went full steam ahead on the new zero-tolerance policy without first preparing for the entirely predictable escalation in family separations. In fact, in an NPR interviewtwo months ago, White House Chief of Staff John Kelly said that separations would act as a deterrent to illegal immigration. He told CNN's Wolf Blizter the same thing the previous year. "Yes, I am considering, in order to deter more movement along this terribly dangerous network, I am considering exactly that," Kelly replied when asked about family separations in a zero-tolerance policy. "They will be well cared for as we deal with their parents."

Rather than deter illegal immigration, however, it has created a firestorm of controversy and a rebellion among the GOP, especially in Congress. Voters are outraged by the practice, with overwhelming majorities calling it unacceptable. The media has seized on the practice, highlighting heartbreaking images and audio of crying children to amplify their activism for a return to more relaxed enforcement. As the Trump administration announces efforts to expand such facilities for children, Congress isn't discussing appropriations for tough enforcement; they're looking for ways to cut off the practice altogether.

GOP Sen. Ted Cruz (Texas) has a good solution, one that is narrowly focused on the collateral damage resulting from zero-tolerance enforcement policy. It would require new shelters to hold families in one place, and add statutory language that mandates against separation except in cases of demonstrable risk of harm to the children. His bill would double the number of immigration judges and require a 14-day turnaround for all cases, enabling families to either qualify for asylum or get prosecuted and deported immediately. That would end "catch and release" and family separations, and would also put an end to the terrible optics that zero-tolerance enforcement necessarily produces under current law.

The real question is why the Trump administration didn't press Congress for these changes before adopting the zero-tolerance policy. The outcomes were not just predictable, they were inevitable. It seems almost unbelievable that no one in the White House predicted what that would mean in political terms, especially in a media environment that has been so hostile to this administration. The reaction from the media and from Democratic opponents has been hyperbolic and ignorant of the complicated history of border enforcement, but it has also been effective in turning the electorate against Trump in the short run. It's a gift to Democrats running for the House and Senate, whose fortunes had flagged since the first of the year.

In other words, all of this blowback could have been avoided with more careful preparation of the political battleground. That's a tough lesson to receive just a few months ahead of a critical midterm election that might determine whether any of the president's nominees get confirmed over the next two years. It's not the first time that this lesson has been taught, either, and one has to wonder whether anyone will learn from it this time.