I discovered the problem and solved the issue. I am posting it here in the off chance that it may help someone else.
It was caused by a conflict with another plugin that seems to be abandoned as it has not been updated since 2018: “Enhanced Media Library”
After disabling the plugin everything worked as expected.