mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Allow to navigate to dropdown entries by keyboard
This commit is contained in:
parent
f70f6c39ce
commit
faa3bea3ab
1 changed files with 24 additions and 0 deletions
|
@ -50,6 +50,25 @@ export default class extends Controller {
|
||||||
plugins: [recentSearchesPlugin],
|
plugins: [recentSearchesPlugin],
|
||||||
openOnFocus: true,
|
openOnFocus: true,
|
||||||
placeholder: "Search for parts",
|
placeholder: "Search for parts",
|
||||||
|
|
||||||
|
// Use a navigator compatible with turbo:
|
||||||
|
navigator: {
|
||||||
|
navigate({ itemUrl }) {
|
||||||
|
window.Turbo.visit(itemUrl, { action: "advance" });
|
||||||
|
},
|
||||||
|
navigateNewTab({ itemUrl }) {
|
||||||
|
const windowReference = window.open(itemUrl, '_blank', 'noopener');
|
||||||
|
|
||||||
|
if (windowReference) {
|
||||||
|
windowReference.focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
navigateNewWindow({ itemUrl }) {
|
||||||
|
window.open(itemUrl, '_blank', 'noopener');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// If the form is submitted, forward the term to the form
|
||||||
onSubmit({state, event, ...setters}) {
|
onSubmit({state, event, ...setters}) {
|
||||||
//Put the current text into each target input field
|
//Put the current text into each target input field
|
||||||
const input = that.inputTarget;
|
const input = that.inputTarget;
|
||||||
|
@ -61,6 +80,8 @@ export default class extends Controller {
|
||||||
input.value = state.query;
|
input.value = state.query;
|
||||||
input.form.requestSubmit();
|
input.form.requestSubmit();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
getSources({ query }) {
|
getSources({ query }) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
@ -71,6 +92,9 @@ export default class extends Controller {
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then((response) => response.json());
|
.then((response) => response.json());
|
||||||
},
|
},
|
||||||
|
getItemUrl({ item }) {
|
||||||
|
return part_detail_uri_template.replace('__ID__', item.id);
|
||||||
|
},
|
||||||
templates: {
|
templates: {
|
||||||
header({ html }) {
|
header({ html }) {
|
||||||
return html`<span class="aa-SourceHeaderTitle">Parts</span>
|
return html`<span class="aa-SourceHeaderTitle">Parts</span>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue