@gsa-tts/graymatter-ui 0.4.10 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gsa-tts/graymatter-ui",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -170,24 +170,45 @@
170
170
  );
171
171
  };
172
172
 
173
+ // Detect help page and set selection state
174
+ const checkHelpPage = () => {
175
+ // Skip check for hash links - they stay on the same page
176
+ if (!helpUrl || helpUrl === '#' || helpUrl.startsWith('#')) {
177
+ return;
178
+ }
179
+
180
+ const location = (
181
+ globalThis as { location?: { pathname?: string; origin?: string } }
182
+ ).location;
183
+ if (location?.origin && location?.pathname) {
184
+ const helpPath = getPathname(helpUrl, location.origin);
185
+ if (helpPath && location.pathname === helpPath) {
186
+ selectedSubNavItemId.set('help');
187
+ } else if (
188
+ get(selectedSubNavItemId) === 'help' &&
189
+ helpPath &&
190
+ location.pathname !== helpPath
191
+ ) {
192
+ // Clear help selection if we navigated away from help page
193
+ selectedSubNavItemId.set(null);
194
+ }
195
+ }
196
+ };
197
+
198
+ checkHelpPage();
199
+
200
+ // Also listen for popstate events (back/forward navigation)
201
+ window.addEventListener('popstate', checkHelpPage);
202
+
173
203
  return () => {
174
204
  window.removeEventListener('layoutTransition', handleLayoutTransition);
175
205
  window.removeEventListener('keydown', handleEscape);
206
+ window.removeEventListener('popstate', checkHelpPage);
176
207
  if (eventListenerCleanup) {
177
208
  eventListenerCleanup();
178
209
  }
179
210
  };
180
211
  }
181
-
182
- const location = (
183
- globalThis as { location?: { pathname?: string; origin?: string } }
184
- ).location;
185
- if (helpUrl && location?.origin && location?.pathname) {
186
- const helpPath = getPathname(helpUrl, location.origin);
187
- if (helpPath && location.pathname === helpPath) {
188
- selectedSubNavItemId.set('help');
189
- }
190
- }
191
212
  });
192
213
 
193
214
  function getPathname(url: string, baseOrigin: string) {
@@ -198,8 +219,15 @@
198
219
  }
199
220
  }
200
221
 
201
- function handleHelpClick() {
222
+ function handleHelpClick(event: MouseEvent) {
202
223
  selectedSubNavItemId.set('help');
224
+
225
+ // If it's a hash link, prevent default to maintain state on same page
226
+ if (helpUrl === '#' || helpUrl?.startsWith('#')) {
227
+ event.preventDefault();
228
+ // State is already set above, so it will persist
229
+ return;
230
+ }
203
231
  }
204
232
 
205
233
  function toggleNav() {
@@ -162,7 +162,7 @@
162
162
  }
163
163
 
164
164
  .nav-item.active .icon {
165
- background-color: var(--ai-color-neutral-200);
165
+ background-color: var(--ai-color-steel-300);
166
166
  border-radius: var(--ai-size-8);
167
167
  }
168
168
 
@@ -74,25 +74,44 @@
74
74
  }, 100);
75
75
  }
76
76
 
77
+ // Detect help page and set selection state (aligned with DesktopSideNav logic)
78
+ const checkHelpPage = () => {
79
+ // Skip check for hash links - they stay on the same page
80
+ if (!helpUrl || helpUrl === '#' || helpUrl.startsWith('#')) {
81
+ return;
82
+ }
83
+
84
+ const location = (
85
+ globalThis as {
86
+ location?: { pathname?: string; origin?: string };
87
+ }
88
+ ).location;
89
+ if (location?.origin && location?.pathname) {
90
+ const helpPath = getPathname(helpUrl, location.origin);
91
+ if (helpPath && location.pathname === helpPath) {
92
+ selectedSubNavItemId.set('help');
93
+ } else if (
94
+ get(selectedSubNavItemId) === 'help' &&
95
+ helpPath &&
96
+ location.pathname !== helpPath
97
+ ) {
98
+ // Clear help selection if we navigated away from help page
99
+ selectedSubNavItemId.set(null);
100
+ }
101
+ }
102
+ };
103
+
104
+ checkHelpPage();
105
+
106
+ // Also listen for popstate events (back/forward navigation)
107
+ window.addEventListener('popstate', checkHelpPage);
108
+
77
109
  return () => {
78
110
  window.removeEventListener('sectionVisible', handleSectionVisible);
111
+ window.removeEventListener('popstate', checkHelpPage);
79
112
  };
80
113
  });
81
114
 
82
- onMount(() => {
83
- const location = (
84
- globalThis as {
85
- location?: { pathname?: string; origin?: string };
86
- }
87
- ).location;
88
- if (helpUrl && location?.origin && location?.pathname) {
89
- const helpPath = getPathname(helpUrl, location.origin);
90
- if (helpPath && location.pathname === helpPath) {
91
- selectedSubNavItemId.set('help');
92
- }
93
- }
94
- });
95
-
96
115
  function getPathname(url: string, baseOrigin: string) {
97
116
  try {
98
117
  return new URL(url, baseOrigin).pathname;
@@ -105,8 +124,15 @@
105
124
  navigationStore.toggleExpanded();
106
125
  }
107
126
 
108
- function handleHelpClick() {
127
+ function handleHelpClick(event: MouseEvent) {
109
128
  selectedSubNavItemId.set('help');
129
+
130
+ // If it's a hash link, prevent default to maintain state on same page
131
+ if (helpUrl === '#' || helpUrl?.startsWith('#')) {
132
+ event.preventDefault();
133
+ // State is already set above, so it will persist
134
+ return;
135
+ }
110
136
  }
111
137
  </script>
112
138
 
@@ -77,6 +77,7 @@ const discover = discoverUrl || '#';
77
77
  profileMenuData={profileMenuData}
78
78
  logoLinkUrl={logoLinkUrl}
79
79
  logoLinkLabel={logoLinkLabel}
80
+ {supplementalMenuData}
80
81
  />
81
82
  <MobileSideMenu client:load {logoLinkUrl} {logoLinkLabel}>
82
83
  <slot name="sub-nav" />
@@ -87,7 +88,7 @@ const discover = discoverUrl || '#';
87
88
  hideDiscover={hideDiscover}
88
89
  apiUrl={api}
89
90
  chatUrl={chat}
90
- consoleUrl={console}
91
+ consoleUrl={consoleApp}
91
92
  discoverUrl={discover}
92
93
  />
93
94
  </nav>