Skip to content

Commit

Permalink
Ensure the querying tables doesn't re-open the side nav
Browse files Browse the repository at this point in the history
  • Loading branch information
sfnelson committed Jul 18, 2024
1 parent 6a909a8 commit ddc8baa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
katalyst-koi (4.11.0)
katalyst-koi (4.11.1)
bcrypt
importmap-rails
katalyst-content
Expand Down Expand Up @@ -231,7 +231,7 @@ GEM
katalyst-kpop
katalyst-tables
view_component
katalyst-tables (3.5.0)
katalyst-tables (3.5.1)
katalyst-html-attributes
view_component
language_server-protocol (3.17.0.3)
Expand Down
18 changes: 18 additions & 0 deletions app/assets/javascripts/koi/controllers/navigation_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { Controller } from "@hotwired/stimulus";
export default class NavigationController extends Controller {
static targets = ["filter"];

connect() {
// using JS registration to make controller easier to add to dom
this.element.addEventListener("turbo:before-morph-attribute", this.onMorphAttribute);
}

disconnected() {
this.element.removeEventListener("turbo:before-morph-attribute", this.onMorphAttribute);
}

focus() {
this.filterTarget.focus();
}
Expand Down Expand Up @@ -78,6 +87,15 @@ export default class NavigationController extends Controller {
this.element.toggleAttribute("aria-expanded");
}

onMorphAttribute = (e) => {
if (e.target !== this.element) return;

switch (e.detail.attributeName) {
case "aria-expanded":
e.preventDefault();
}
}

get links() {
return Array.from(this.element.querySelectorAll("li:has(> a)"));
}
Expand Down
2 changes: 1 addition & 1 deletion katalyst-koi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "katalyst-koi"
s.version = "4.11.0"
s.version = "4.11.1"
s.authors = ["Katalyst Interactive"]
s.email = ["[email protected]"]

Expand Down

0 comments on commit ddc8baa

Please sign in to comment.