#3308·nebular

NbLayoutDirectionService: Cannot read properties of null (reading 'setAttribute')

Author: wnabilCreated Dec 24, 2025Updated Dec 24, 2025

NbLayoutDirectionService throws error on second direction change. The error doesn't appear when changing the direction for the first time

ERROR TypeError: Cannot read properties of null (reading 'setAttribute')
    at OverlayRef._updateElementDirection (overlay-module-6629f4c6.mjs:1171:16)
    at OverlayRef.setDirection (overlay-module-6629f4c6.mjs:1133:10)
    at Object.next (nebular-theme.mjs:4169:74)
    at ConsumerObserver2.next (Subscriber.js:90:25)
    at Subscriber2._next (Subscriber.js:59:22)
    at Subscriber2.next (Subscriber.js:32:12)
    at Subject.js:41:22
    at errorContext (errorContext.js:23:5)
    at Subject2.next (Subject.js:31:5)
    at Object.next (share.js:57:25)

@nebular/theme: 15.0.0

typescript
  setAppLanguage() {
    const language =
      this.currentUserProfile?.preferred_langcode ||
      navigator.language.split('-')[0] ||
      'en';
    this.translateService.use(language);

    const direction =
      language === 'en' ? NbLayoutDirection.LTR : NbLayoutDirection.RTL;
    this.layoutDirectionService.setDirection(direction);
  }