Skip to content

Commit

Permalink
fix: ensure the pointer init class is removed when updating locked st…
Browse files Browse the repository at this point in the history
…atus
  • Loading branch information
WilliamDASILVA committed Nov 18, 2024
1 parent 36572c3 commit 66e38d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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('');
});
});

0 comments on commit 66e38d8

Please sign in to comment.