Yes but Johnston felt that McClellan's massing of artillery at Yorktown was ominous, and he fall back "accordingly," insecure in his ability to hold the line against enemy siege guns.
He also had to deal with Union forces landing in his rear at Eltham Landing, which he opposed, but the threat of future landings still lingered.
While a narrow neck of land is often powerful to defend, as in the Bermuda Hundred Campaign, when Butler was "bottled up," nonetheless the York River above the Peninsula gave McClellan the ability to outflank Johnston's position.
Of Course, Lee, or some other bold general, may have taken your view of things and resisted to the last on the Peninsula, but Johnston fell right into McClellan's way of seeing things, and retreated "accordingly."