Skip to content

Commit

Permalink
prevent webkit from going back to about:blank
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Jan 8, 2025
1 parent 5e7c09d commit b9e3d2f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/dashboard/test/dashboard-keyboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ describe('dashboard - keyboard interaction', () => {
expect(spy.firstCall.args[0].detail).to.eql({ item: { id: 0 }, value: true });
});

(isChrome || isFirefox ? it : it.skip)('should not remove the widget on backspace', async () => {
(isChrome || isFirefox ? it : it.skip)('should not remove the widget on Delete', async () => {
await sendKeys({ press: 'Tab' });
await sendKeys({ press: 'Backspace' });
await sendKeys({ press: 'Delete' });
expect(dashboard.items).to.eql([{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

Expand Down Expand Up @@ -181,8 +181,8 @@ describe('dashboard - keyboard interaction', () => {
expect(widget.hasAttribute('focused')).to.be.false;
});

it('should remove the widget on backspace', async () => {
await sendKeys({ press: 'Backspace' });
it('should remove the widget on Delete', async () => {
await sendKeys({ press: 'Delete' });
expect(dashboard.items).to.eql([{ id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

Expand All @@ -191,10 +191,10 @@ describe('dashboard - keyboard interaction', () => {
expect(dashboard.items).to.eql([{ id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

it('should dispatch an item removed event on backspace', async () => {
it('should dispatch an item removed event on Delete', async () => {
const spy = sinon.spy();
dashboard.addEventListener('dashboard-item-removed', spy);
await sendKeys({ press: 'Backspace' });
await sendKeys({ press: 'Delete' });
expect(spy.calledOnce).to.be.true;
expect(spy.firstCall.args[0].detail.item).to.eql({ id: 0 });
expect(spy.firstCall.args[0].detail.items).to.eql(dashboard.items);
Expand Down Expand Up @@ -286,9 +286,9 @@ describe('dashboard - keyboard interaction', () => {
expect(dashboard.items).to.eql([{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }]);
});

it('should cancel the default action on backspace', async () => {
it('should cancel the default action on Delete', async () => {
keydownSpy.resetHistory();
await sendKeys({ press: 'Backspace' });
await sendKeys({ press: 'Delete' });
expect(keydownSpy.firstCall.args[0].defaultPrevented).to.be.true;
});

Expand Down
8 changes: 8 additions & 0 deletions packages/multi-select-combo-box/test/chips.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ describe('chips', () => {

it('should not mark last chip on Backspace as focused when readonly', async () => {
comboBox.readonly = true;
// Prevent navigating to about:blank in WebKit
inputElement.addEventListener(
'keydown',
(e) => {
e.preventDefault();
},
{ once: true },
);
await sendKeys({ press: 'Backspace' });
const chips = getChips(comboBox);
expect(chips[1].hasAttribute('focused')).to.be.false;
Expand Down

0 comments on commit b9e3d2f

Please # to comment.