sonance-brand-mcp 1.3.82 → 1.3.84

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.
@@ -155,35 +155,6 @@ export function SonanceDevTools() {
155
155
  return () => observer.disconnect();
156
156
  }, []);
157
157
 
158
- // Protect DevTools from host app event capture (e.g., modal focus traps)
159
- // This uses capture phase to intercept events BEFORE host app listeners can grab them
160
- useEffect(() => {
161
- if (!mounted || !isOpen) return;
162
-
163
- const protectDevToolsEvents = (e: Event) => {
164
- // Check if the event target is inside the DevTools panel
165
- const devToolsPanel = document.querySelector('[data-sonance-devtools="true"]');
166
- if (devToolsPanel?.contains(e.target as Node)) {
167
- // Stop the event from being captured by host app listeners
168
- e.stopImmediatePropagation();
169
- }
170
- };
171
-
172
- // Capture phase (third param = true) runs before bubble phase
173
- // stopImmediatePropagation prevents other capture listeners from running
174
- const events = ['pointerdown', 'mousedown', 'touchstart', 'click', 'focus', 'focusin'];
175
-
176
- events.forEach(eventType => {
177
- document.addEventListener(eventType, protectDevToolsEvents, true);
178
- });
179
-
180
- return () => {
181
- events.forEach(eventType => {
182
- document.removeEventListener(eventType, protectDevToolsEvents, true);
183
- });
184
- };
185
- }, [mounted, isOpen]);
186
-
187
158
  // Component-specific style overrides (for scalable, project-agnostic styling)
188
159
  // Key: component type (e.g., "card", "button-primary", "card:variant123"), Value: style overrides
189
160
  const [componentOverrides, setComponentOverrides] = useState<Record<string, ComponentStyle>>({});
@@ -396,7 +396,27 @@ export function ChatInterface({
396
396
  )}
397
397
 
398
398
  {/* Input */}
399
- <div className="flex gap-2">
399
+ <div
400
+ className="flex gap-2"
401
+ onPointerDown={(e) => {
402
+ // Force focus to input when clicking anywhere in this container
403
+ // This bypasses modal focus traps by using requestAnimationFrame
404
+ e.stopPropagation();
405
+ const input = inputRef.current;
406
+ if (input && !isProcessing) {
407
+ // Blur any currently focused element first (escape focus trap)
408
+ if (document.activeElement && document.activeElement !== input) {
409
+ (document.activeElement as HTMLElement).blur?.();
410
+ }
411
+ // Use rAF to ensure focus happens after any focus trap logic runs
412
+ requestAnimationFrame(() => {
413
+ input.focus();
414
+ // Also try native focus method as fallback
415
+ input.click();
416
+ });
417
+ }
418
+ }}
419
+ >
400
420
  <input
401
421
  ref={inputRef}
402
422
  type="text"
@@ -404,15 +424,31 @@ export function ChatInterface({
404
424
  onChange={(e) => setInput(e.target.value)}
405
425
  onClick={(e) => {
406
426
  e.stopPropagation();
407
- inputRef.current?.focus();
427
+ e.preventDefault();
428
+ // Force focus using multiple strategies
429
+ const input = inputRef.current;
430
+ if (input) {
431
+ // Escape any focus trap
432
+ if (document.activeElement && document.activeElement !== input) {
433
+ (document.activeElement as HTMLElement).blur?.();
434
+ }
435
+ input.focus();
436
+ }
408
437
  }}
409
438
  onPointerDown={(e) => {
410
439
  e.stopPropagation();
411
- inputRef.current?.focus();
440
+ // Don't preventDefault here - let native click handling work
441
+ const input = inputRef.current;
442
+ if (input) {
443
+ requestAnimationFrame(() => input.focus());
444
+ }
412
445
  }}
413
446
  onMouseDown={(e) => {
414
447
  e.stopPropagation();
415
- inputRef.current?.focus();
448
+ const input = inputRef.current;
449
+ if (input) {
450
+ requestAnimationFrame(() => input.focus());
451
+ }
416
452
  }}
417
453
  onKeyDown={(e) => {
418
454
  if (e.key === "Enter" && !e.shiftKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.82",
3
+ "version": "1.3.84",
4
4
  "description": "MCP Server for Sonance Brand Guidelines and Component Library - gives Claude instant access to brand colors, typography, and UI components.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",