Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the resizer is applied on the properly selected component #6128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/commands/view/SelectComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ export default {
*/
select(model: Component, event = {}) {
if (!model) return;
this.editor.select(model, { event, useValid: true });
this.initResize(model);
const { em } = this;
em.setSelected(model, { event, useValid: true });
// Ensure we're passing the proper selected component #6096
this.initResize(em.getSelected());
},

/**
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/dom_components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export enum ComponentsEvents {
update = 'component:update',
updateInside = 'component:update-inside',

/**
* @event `component:select` Component selected.
* @example
* editor.on('component:select', (component) => { ... });
*/
select = 'component:select',
selectBefore = 'component:select:before',

/**
* @event `symbol:main:add` Added new main symbol.
* @example
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/editor/model/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { AddComponentsOption, ComponentAdd, DragMode } from '../../dom_component
import ComponentWrapper from '../../dom_components/model/ComponentWrapper';
import { CanvasSpotBuiltInTypes } from '../../canvas/model/CanvasSpot';
import DataSourceManager from '../../data_sources';
import { ComponentsEvents } from '../../dom_components/types';

Backbone.$ = $;

Expand Down Expand Up @@ -507,7 +508,7 @@ export default class EditorModel extends Model {

models.forEach((model) => {
if (model) {
this.trigger('component:select:before', model, opts);
this.trigger(ComponentsEvents.selectBefore, model, opts);

// Check for valid selectable
if (!model.get('selectable') || opts.abort) {
Expand Down Expand Up @@ -592,7 +593,7 @@ export default class EditorModel extends Model {
toDeselect.forEach((cmp) => this.removeSelected(cmp, opts));

selected.addComponent(model, opts);
this.trigger('component:select', model, opts);
this.trigger(ComponentsEvents.select, model, opts);
this.Canvas.addSpot({
type: CanvasSpotBuiltInTypes.Select,
component: model,
Expand Down