Skip to content

Latest commit

 

History

History
86 lines (59 loc) · 2.59 KB

File metadata and controls

86 lines (59 loc) · 2.59 KB

Cross-Browser Backdrop-Filter Solution

The Problem

Different browsers handle nested backdrop-filter elements differently:

  • Chrome/Chromium: Has a bug where child backdrop-filter effects are removed when nested within parent elements that also have backdrop-filter

  • Firefox: Requires parent elements to have backdrop-filter for child backdrop-filter elements to work properly

    • This is the opposite behavior from Chrome's bug

Our Specific Issue

chat-input (backdrop-filter OR no backdrop-filter?)
└── .model-menu (backdrop-filter: blur(12px))
  • With backdrop-filter on chat-input:

    • ✅ Firefox: model-menu blur works
    • ❌ Chrome: model-menu blur blocked
  • Without backdrop-filter on chat-input:

    • ❌ Firefox: model-menu blur doesn't work
    • ✅ Chrome: model-menu blur works

The Solution: Browser-Specific CSS

Firefox-Specific Rules

/* Firefox-specific: Enable backdrop-filter for child elements to work */
@supports (-moz-appearance: none) {
  backdrop-filter: blur(80px);
  -webkit-backdrop-filter: blur(80px);
  background: rgba(37, 37, 37, 0.7);
}

Chrome-Specific Fallback

/* Chrome-specific: Use more opaque background when backdrop-filter may not work */
@supports (-webkit-appearance: none) and (not (-moz-appearance: none)) {
  background: rgba(29, 29, 29, 0.95);
  border: 1px solid rgba(90, 90, 90, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

How It Works

  1. Default State: No backdrop-filter on chat-input (Chrome-friendly)
  2. Firefox Detection: Uses @supports (-moz-appearance: none) to detect Firefox and enable backdrop-filter
  3. Chrome Enhancement: Uses @supports (-webkit-appearance: none) and (not (-moz-appearance: none)) to detect Chrome and provide enhanced styling without relying on backdrop-filter

Testing

Firefox

  • Parent chat-input has backdrop-filter ✅
  • Child .model-menu backdrop-filter works ✅

Chrome

  • Parent chat-input has no backdrop-filter ✅
  • Child .model-menu backdrop-filter works ✅
  • Enhanced visual styling with shadows and opacity ✅

Safari

  • Should work like Chrome (WebKit-based)
  • Fallback to enhanced styling

Browser Support

  • ✅ Chrome/Chromium (all versions)
  • ✅ Firefox (all modern versions)
  • ✅ Safari (all modern versions)
  • ✅ Edge (Chromium-based)

This solution provides optimal visual experience across all major browsers while working around their different backdrop-filter implementations.