-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da36f4d
commit 3bea2cd
Showing
4 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This file is part of Bileto. | ||
// Copyright 2022-2023 Probesys | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
import { FOCUSABLE_ELEMENTS } from '@/query_selectors.js'; | ||
|
||
export default class extends Controller { | ||
static get targets () { | ||
return ['panel']; | ||
} | ||
|
||
change (event) { | ||
this.panelTargets.forEach((panel) => { | ||
panel.hidden = panel.id !== event.params.for; | ||
|
||
if (!panel.hidden) { | ||
const focusableElements = Array.from(panel.querySelectorAll(FOCUSABLE_ELEMENTS)); | ||
if (focusableElements.length > 0) { | ||
focusableElements[0].focus(); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This file is part of Bileto. | ||
// Copyright 2022-2023 Probesys | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
export const FOCUSABLE_ELEMENTS = [ | ||
'a[href]:not([tabindex="-1"])', | ||
'button:not([disabled]):not([tabindex="-1"])', | ||
'input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])', | ||
'select:not([disabled]):not([tabindex="-1"])', | ||
'textarea:not([disabled]):not([tabindex="-1"])', | ||
'[tabindex]:not([tabindex="-1"])', | ||
]; |