WHEN A politician flip-flops, an editorial writer’s instinct is to pounce. When the politician flip-flops a half-dozen times in a week, as President Trump has done, the instinct is almost irresistible.

Nor is the pouncing a childish game of “gotcha,” as the politician’s defenders in such circumstances often maintain. People who voted for Mr. Trump on the expectation that he was going to keep his promises — to rewrite the North American Free Trade Agreement, say, or tear up the Iran nuclear deal on the first day of his presidency — have reason to feel aggrieved. Even voters who did not support those positions have reason to feel confused. Unpredictability can be an asset, to the extent it keeps adversaries off balance, but it can be a liability, too, especially for allies who do not know what to think or whom to trust. If NATO was obsolete last week and essential this week, what will it be next week?

Nonetheless, when a president moves from being so wrong to being so right on such important questions, the sensible response is not to carp but to celebrate, however cautiously. Syrian President Bashar al-Assad is a “butcher,” and it is hugely important that the United States recognize as much. It should not be tolerable to the United States for a dictator such as Mr. Assad to drop ghastly chemical weapons on children or for a dictator such as Russian President Vladi­mir Putin to lie about the war crime. The NATO alliance has been a force for peace and freedom for decades, and Mr. Trump is right to welcome its enlargement and work toward its improvement. He is right that China is no longer a currency manipulator, and it does not serve U.S. interests to distort the facts.

Of course, there are 1,001 areas where we still ferociously disagree with Mr. Trump, and we express no confidence that he will stick to his new positions where we do agree. But we think there are two particular reasons to take heart from his recent shifts regarding the U.S. role in the world.

The first is they may reflect the thinking and advice of an excellent national security team that Mr. Trump has begun to shape. He fired the wildly unsuitable Michael Flynn as national security adviser and replaced him with the comparably well-qualified H.R. McMaster. He removed Stephen K. Bannon, leader of his “America First” nationalist advisers, from the National Security Council. He named sensible people to his most important Cabinet positions, especially Jim Mattis to the Defense Department and Rex Tillerson to the State Department. It would not be surprising if these sensible people were telling the president that the world is safer when the United States is engaged and leading on behalf of values such as self-determination. We should be grateful if Mr. Trump is paying attention, and even more grateful if he would let them fill out their teams and develop a strategy.

The second reason to take some encouragement is that Mr. Trump’s shifts align him more closely with the traditional moral values of the people he was elected to lead. Naturally, most Americans believe their government should put their welfare first. Many do not want their young men and women fighting wars far from home. But most Americans do not feel comfortable with the harsh selfishness they heard in Mr. Trump’s inaugural address. They want the United States to be in sympathy with people who are fighting for freedom, not with the agents of their death and repression. If the magnet of American magnanimity is tugging Mr. Trump closer to those mainstream values, that is to be welcomed.