View.theme.enable() not working on project page in Jira

Hi there,

I hope anyone can help here: I am trying to add theming to my Forge apps, so that it displays in dark when a user has dark mode enabled. It works fine for an app that opens a modal dialog via issue action. However, for another app, where we have an app project page, I tried to do it exactly the same way.
I added

import { view } from '@forge/bridge';

view.theme.enable()

as mentioned here: https://developer.atlassian.com/platform/forge/design-tokens-and-theming/

When I try to load the app, it doesn’t load and I get this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'enable')

When I log ‘view’ I see that there isn’t a theme attribute in the JSON.

Does anyone have an idea what I am doing wrong? Does it not work correctly on project pages in Jira yet?

Hi there @ij-s

I’ve just tried to replicate this in my own Custom UI app that displays on a project page, but I was unable to - I tried in a few different project types as well to see if that could be the issue.

Are you seeing this error across multiple different projects?
Have you tried in a different instance with the same result?

I’m wondering if somehow your instance, or project is missing this setting.

Let me know how you go,
Mel

Hi @mpaisley

Thanks for the answer. I tried it on several instances and in different project types and the behaviour was the same.
Then I checked the version of forge bridge I used. It was 2.4.0, after updating to version 2.6.0 the problem didn’t occur again :+1:. So that was the reason why it wasn’t working and I think we can close this topic :slight_smile:

2 Likes