diff --git a/assets/js/session/index.js b/assets/js/session/index.js index ce98be39d..3b2bcfb71 100644 --- a/assets/js/session/index.js +++ b/assets/js/session/index.js @@ -186,7 +186,11 @@ function handleDocumentKeyDown(hook, event) { */ function handleDocumentMouseDown(hook, event) { // If click targets cell actions, keep the focus as is - if (event.target.closest(`[data-element="actions"]`)) { + if ( + event.target.closest( + `[data-element="actions"], [data-element="insert-buttons"]` + ) + ) { // If the pencil icon is clicked, enter insert mode if (event.target.closest(`[data-element="enable-insert-mode-button"]`)) { setInsertMode(hook, true); @@ -460,6 +464,10 @@ function handleCellMoved(hook, cellId) { } function handleSectionInserted(hook, sectionId) { + if (hook.state.focusedSectionId) { + setFocusedCell(hook, null); + } + const section = getSectionById(sectionId); const nameElement = section.querySelector(`[data-element="section-name"]`); nameElement.focus({ preventScroll: true }); diff --git a/lib/livebook_web/live/insert_buttons_component.ex b/lib/livebook_web/live/insert_buttons_component.ex index e16c1a249..8234f38de 100644 --- a/lib/livebook_web/live/insert_buttons_component.ex +++ b/lib/livebook_web/live/insert_buttons_component.ex @@ -3,7 +3,7 @@ defmodule LivebookWeb.InsertButtonsComponent do def render(assigns) do ~L""" -
+
hover:opacity-100 focus-within:opacity-100 flex space-x-2 justify-center items-center">