Skip to content

Commit

Permalink
fix(ld-radio): remove redundant input event dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdiakur committed Nov 16, 2021
1 parent 1e95789 commit b063726
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
3 changes: 1 addition & 2 deletions src/liquid/components/ld-radio/ld-radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,14 @@ export class LdRadio implements InnerFocusable {
}

this.checked = true
this.el.dispatchEvent(new Event('input', { bubbles: true, composed: true }))
}

private focusAndSelect(dir: 'next' | 'prev') {
const ldRadios = Array.from(document.querySelectorAll('ld-radio')).filter(
(ldRadio) => ldRadio.getAttribute('name') === this.name
)
ldRadios.forEach((ldRadio, index) => {
if (ldRadio === ((this.el as unknown) as HTMLLdRadioElement)) {
if (ldRadio === (this.el as unknown as HTMLLdRadioElement)) {
const targetLdRadio = ldRadios[index + (dir === 'next' ? 1 : -1)]
if (targetLdRadio) {
targetLdRadio.focusInner()
Expand Down
14 changes: 0 additions & 14 deletions src/liquid/components/ld-radio/test/ld-radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,6 @@ describe('ld-radio', () => {
expect(spyBlur).toHaveBeenCalled()
})

it('emits input event on click', async () => {
const page = await newSpecPage({
components: [LdRadio],
html: `<ld-radio />`,
})
const ldRadio = page.root

const spyInput = jest.fn()
ldRadio.addEventListener('input', spyInput)
ldRadio.click()

expect(spyInput).toHaveBeenCalled()
})

it('allows to set inner focus', async () => {
const page = await newSpecPage({
components: [LdRadio],
Expand Down

0 comments on commit b063726

Please sign in to comment.