When creating an extension that introduces a new gallery mode (with https://www.mediawiki.org/wiki/Manual:Hooks/GalleryGetModes) it's not possible to edit said gallery using the visual editor. Trying to do so results in a JavaScript error:
Uncaught TypeError: Cannot read properties of null (reading 'getData') at ve.ui.MWGalleryDialog.onModeDropdownChange
Apparently the cause is that extensions/VisualEditor/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js has the admissible gallery modes hard-coded (here). Manually adding a new mode to the list (at line 265 aprox) results in no error and successful editing using the visual editor.