Skip to content

Commit

Permalink
Fixed bug where buttons added after page load don't activate JS behav…
Browse files Browse the repository at this point in the history
…iours

Fixes #906
  • Loading branch information
andymantell committed Nov 30, 2023
1 parent ef40d37 commit 04aaa42
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Button {
event.preventDefault()
// trigger the target's click event
target.click()
console.log('Space click')
}
}

Expand Down Expand Up @@ -63,8 +64,5 @@ class Button {
}

export default () => {
const buttons = document.querySelectorAll('[data-module="nhsuk-button"]')
buttons.forEach((el) => {
new Button(el).init()
})
new Button(document).init()
}

0 comments on commit 04aaa42

Please sign in to comment.