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

fix: ensure the pointer-init class is removed when updating the "locked" state #6312

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/core/src/dom_components/view/ComponentView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ TComp> {
const hoveredCls = `${ppfx}hovered`;
const noPointerCls = `${ppfx}no-pointer`;
const pointerInitCls = `${ppfx}pointer-init`;
const toRemove = [selectedCls, selectedParentCls, freezedCls, hoveredCls, noPointerCls];
const toRemove = [selectedCls, selectedParentCls, freezedCls, hoveredCls, noPointerCls, pointerInitCls];
const selCls = extHl && !opts.noExtHl ? '' : selectedCls;
this.$el.removeClass(toRemove.join(' '));
const actualCls = el.getAttribute('class') || '';
Expand Down
16 changes: 16 additions & 0 deletions packages/core/test/specs/dom_components/view/ComponentView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,20 @@ describe('ComponentView', () => {
const result = model.getAttributes();
expect(result.class).toEqual(undefined);
});

test('updateStatus removes previous classes and adds new ones', () => {
model.addClass('selected');

model.set('locked', true);
view.updateStatus();
expect(view.el.getAttribute('class')).toEqual('no-pointer');

model.set('locked', false);
view.updateStatus();
expect(view.el.getAttribute('class')).toEqual('pointer-init');

model.set('locked');
view.updateStatus();
expect(view.el.getAttribute('class')).toEqual('');
});
});