Skip to content

Commit

Permalink
[#62] Fix "up" key does not close open menu/accordion. (#114)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Fernandes <“joshua.1234511@yahoo.in”>
  • Loading branch information
joshua-salsadigital and Joshua Fernandes authored Mar 15, 2024
1 parent 8909fa9 commit b3f22a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/00-base/collapsible/collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ CivicThemeCollapsible.prototype.keydownEvent = function (e) {
if (this !== document) {
// Up.
if (e.which === 38 && !e.shiftKey) {
this.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { animate: true } }));
this.dispatchEvent(new CustomEvent('ct.collapsible.collapse', { bubbles: true, detail: { animate: true, keydown: true } }));
return;
}

Expand Down Expand Up @@ -255,7 +255,11 @@ CivicThemeCollapsible.prototype.collapse = function (animate, evt) {
}

if (evt && evt.target) {
if (evt.currentTarget !== t.el || evt.target !== t.el) {
if (evt.detail.keydown) {
if (evt.target.closest('[data-collapsible="true"]') !== t.el) {
return;
}
} else if (evt.currentTarget !== t.el || evt.target !== t.el) {
return;
}
}
Expand Down

1 comment on commit b3f22a2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.