Problem/Motivation
On certain pages including /admin/structure/menu/manage/admin and /admin/structure/types/add, the machine name field appears, and then is immediately hidden by JavaScript.
Sometimes this field is read only (like on the menu pages) and sometimes its editable (like on the add content type page), and is populated by JavaScript (via machine-name.js). Note that when this is the case, if the form is submitted with a duplicate machine name the field should become visible.
Steps to reproduce
Navigate to /admin/structure/menu/manage/admin and /admin/structure/types/add and notice the layout shift.
Proposed resolution
Use modern CSS including :has() and the at-media scripting feature to reduce the layout shift.
Note the JS that does the hiding is at https://git.drupalcode.org/project/drupal/-/blob/11.x/core/misc/machine-.... In the MR below, I've used CSS :has() to hide the same selectors that the JS affects. I've also modified the selector so that it doesn't do any hiding if the form item is in an error state, which happens when a duplicate content type is created (example, try to create another content type called article and the field will appear)
Remaining tasks
do it, review it, commit it.

| Comment | File | Size | Author |
|---|---|---|---|
| machine-name.png | 231.12 KB | mherchel |
Issue fork drupal-3441175
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mherchelUpdating IS.
Comment #4
mherchelComment #5
smustgrave commentedTested on Chrome 123.0.6312.122
The toolbar flicker kept grabbing my eye. But the machine name field does not appear or reappear
Comment #6
nod_Putting back at NW to make sure that in case JS crashes or can't downaload completely this still works.
Comment #8
gauravvvv commentedI've updated the MR for cases when JavaScript is unsupported or disabled.
Comment #9
nod_The issue is with Js being half-available. if some of the JS execute but not the rest the feature could stay broken, see #3441124-12: Views UI action buttons create janky layout shift on page load for a possible fix