diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 233218feb..2763f793e 100644 Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index 65d7ceaeb..6c6bf1d1f 100644 Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ diff --git a/netbox/project-static/src/tomSelect.ts b/netbox/project-static/src/tomSelect.ts index f890d37e1..22cc6d707 100644 --- a/netbox/project-static/src/tomSelect.ts +++ b/netbox/project-static/src/tomSelect.ts @@ -2,6 +2,19 @@ import { getElements } from './util'; import { TomOption } from 'tom-select/src/types'; import TomSelect from 'tom-select'; + +class DynamicTomSelect extends TomSelect { + + // Override load() to automatically clear any cached options. (Only options included + // in the API response should be present.) + load(value: string) { + this.clearOptions(); + super.load(value); + } + +} + +// Initialize elements which are populated via a REST API call function initDynamicSelects(): void { for (const select of getElements('select.api-select')) { const api_url = select.getAttribute('data-url') as string; - new TomSelect(select, { + new DynamicTomSelect(select, { plugins: ['clear_button'], valueField: 'id', labelField: 'display', - searchField: ['name'], + searchField: [], copyClassesToDropdown: false, dropdownParent: 'body', controlInput: '', @@ -40,6 +54,7 @@ function initDynamicSelects(): void { } +// Initialize color selection fields function initColorSelects(): void { for (const select of getElements('select.color-select')) {