Skip to content

Commit

Permalink
Merge pull request #3248 from alphagov/tab-click-target
Browse files Browse the repository at this point in the history
Tweak tab clicks to use `event.currentTarget`
  • Loading branch information
colinrotherham authored Feb 8, 2023
2 parents be84283 + a323c91 commit a6572a5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/govuk/components/tabs/tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,16 @@ Tabs.prototype.unsetAttributes = function ($tab) {
* Handle tab link clicks
*
* @param {MouseEvent} event - Mouse click event
* @returns {void | false} Returns void, or false within tab link
* @returns {void} Returns void
*/
Tabs.prototype.onTabClick = function (event) {
var $currentTab = this.getCurrentTab()
var $nextTab = event.target
var $nextTab = event.currentTarget

if (!$currentTab || !$nextTab) {
return
}

// Allow events on child DOM elements to bubble up to tab parent
if (!$nextTab.classList.contains('govuk-tabs__tab')) {
return false
}

event.preventDefault()

this.hideTab($currentTab)
Expand Down

0 comments on commit a6572a5

Please sign in to comment.