diff --git a/app/assets/javascripts/discourse/app/components/modal/sidebar-section-form.js b/app/assets/javascripts/discourse/app/components/modal/sidebar-section-form.js index 80473d49371..44ca1067ef4 100644 --- a/app/assets/javascripts/discourse/app/components/modal/sidebar-section-form.js +++ b/app/assets/javascripts/discourse/app/components/modal/sidebar-section-form.js @@ -9,7 +9,7 @@ import { extractError } from "discourse/lib/ajax-error"; import { SIDEBAR_SECTION, SIDEBAR_URL } from "discourse/lib/constants"; import RouteInfoHelper from "discourse/lib/sidebar/route-info-helper"; import { sanitize } from "discourse/lib/text"; -import { bind } from "discourse-common/utils/decorators"; +import { afterRender, bind } from "discourse-common/utils/decorators"; import I18n from "discourse-i18n"; const FULL_RELOAD_LINKS_REGEX = [ @@ -383,6 +383,13 @@ export default class SidebarSectionForm extends Component { : "sidebar.sections.custom.add"; } + @afterRender + focusNewRowInput(id) { + document + .querySelector(`[data-row-id="${id}"] .icon-picker summary`) + .focus(); + } + @bind setDraggedLink(link) { this.draggedLink = link; @@ -445,6 +452,8 @@ export default class SidebarSectionForm extends Component { segment: "primary", }) ); + + this.focusNewRowInput(this.nextObjectId); } @action @@ -457,6 +466,8 @@ export default class SidebarSectionForm extends Component { segment: "secondary", }) ); + + this.focusNewRowInput(this.nextObjectId); } @action diff --git a/app/assets/javascripts/discourse/app/components/sidebar/section-form-link.hbs b/app/assets/javascripts/discourse/app/components/sidebar/section-form-link.hbs index cb24ea34818..8e22a47ed09 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/section-form-link.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/section-form-link.hbs @@ -12,6 +12,7 @@ {{on "dragend" this.dragEnd}} {{on "drop" this.dropItem}} role="row" + data-row-id={{@link.objectId}} > {{#unless this.site.mobileView}}