Gutenberg: how to force sidebar to be always open on post edit screen

Add this to your functions.php

if (is_admin()) { 
  function myplugin_show_editor_sidebar_by_default() {
    ob_start();
    ?>
      window.onload = function() {
        const isEditorSidebarOpened = wp.data.select( 'core/edit-post' ).isEditorSidebarOpened();
        if ( ! isEditorSidebarOpened ) {
          wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar('edit-post/document');
        }
      };
    <?php
    wp_add_inline_script( 'wp-blocks', ob_get_clean() );
  }
  add_action( 'enqueue_block_editor_assets', 'myplugin_show_editor_sidebar_by_default' );
}