Unlike all other action bars, main one doesn’t have an “always show buttons” toggle to hide empty and unused ability slots.
After a lot of frustration I found an addon which fixes an overlooked feature. This functionality should be included by default and it is long overdue. I tried hiding it myself but I never could find the correct string of text.
https://www.curseforge.com/wow/addons/hide-primary-action-bar-empty-buttons
Unfortunately, the addon has a lot of bugs and sometimes hides more than intended, especially for Druids and Rogues when it comes to automatic action bar switching for different stances and stealth mode (some errors with Dragonriding as well).