Skip to content

Commit 1a47815

Browse files
Merge pull request #7050 from netbox-community/7034-vlangroup-scope-selectors
Fixes #7034: Update VLAN Scope parent selectors and run change handler on load
2 parents 9813f3b + e5643fb commit 1a47815

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* [#6982](https://github.com/netbox-community/netbox/issues/6982) - Fix styling of empty dropdown list under dark mode
1515
* [#6996](https://github.com/netbox-community/netbox/issues/6996) - Global search bar should be full width on mobile
1616
* [#7001](https://github.com/netbox-community/netbox/issues/7001) - Fix page focus on load
17+
* [#7034](https://github.com/netbox-community/netbox/issues/7034) - Fix toggling of VLAN group scope selector fields
1718

1819
---
1920

netbox/project-static/dist/netbox.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netbox/project-static/dist/netbox.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netbox/project-static/src/forms/scopeSelector.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getElements } from '../util';
1+
import { getElements, toggleVisibility } from '../util';
22

33
type ShowHideMap = {
44
default: { hide: string[]; show: string[] };
@@ -62,19 +62,21 @@ const showHideMap: ShowHideMap = {
6262
*/
6363
function toggleParentVisibility(query: string, action: 'show' | 'hide') {
6464
for (const element of getElements(query)) {
65-
if (action === 'show') {
66-
element.parentElement?.classList.remove('d-none', 'invisible');
67-
} else {
68-
element.parentElement?.classList.add('d-none', 'invisible');
65+
const parent = element.parentElement?.parentElement as Nullable<HTMLDivElement>;
66+
if (parent !== null) {
67+
if (action === 'show') {
68+
toggleVisibility(parent, 'show');
69+
} else {
70+
toggleVisibility(parent, 'hide');
71+
}
6972
}
7073
}
7174
}
7275

7376
/**
7477
* Handle changes to the Scope Type field.
7578
*/
76-
function handleScopeChange(event: Event) {
77-
const element = event.currentTarget as HTMLSelectElement;
79+
function handleScopeChange(element: HTMLSelectElement) {
7880
// Scope type's innerText looks something like `DCIM > region`.
7981
const scopeType = element.options[element.selectedIndex].innerText.toLowerCase();
8082

@@ -104,6 +106,7 @@ function handleScopeChange(event: Event) {
104106
*/
105107
export function initScopeSelector(): void {
106108
for (const element of getElements<HTMLSelectElement>('#id_scope_type')) {
107-
element.addEventListener('change', handleScopeChange);
109+
handleScopeChange(element);
110+
element.addEventListener('change', () => handleScopeChange(element));
108111
}
109112
}

0 commit comments

Comments
 (0)