Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholder Control not working in Teams theme #1130

Closed
DJoshi23 opened this issue Feb 15, 2022 · 20 comments
Closed

Placeholder Control not working in Teams theme #1130

DJoshi23 opened this issue Feb 15, 2022 · 20 comments
Assignees
Labels
area:new-control Needs: Author Feedback no-recent-activity status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. type:enhancement New feature or enhancement of existing capability

Comments

@DJoshi23
Copy link

DJoshi23 commented Feb 15, 2022

Hi,

I have created SPFx webpart with Placeholder Control and added webpart in Teams application as a Teams Tab.

Issue Description : If I change the Teams Theme to High contrast then Placeholder Control not looking properly. Please find the below image for your reference

image

and same type of theme issue i am facing in other control as well .

Version :

SPFX version : 1.12.1
"@pnp/spfx-controls-react": "3.2.1"
"@pnp/spfx-property-controls": "^3.2.0",

Thank you in advance

@ghost
Copy link

ghost commented Feb 15, 2022

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Feb 15, 2022
@github-actions
Copy link

Thank you for submitting your first issue to this project.

@joelfmrodrigues
Copy link
Collaborator

Hi @DJoshi23, many thanks for reporting this issue. Would you be interested in submitting a PR?
If so, please keep in mind that the solution has been upgraded to SPFx 1.14.0, which introduces some changes to themes
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/release-1.14#web-part-lifecycle-method-for-theme-changes

@joelfmrodrigues joelfmrodrigues added help wanted Good First Issue 🏆 type:enhancement New feature or enhancement of existing capability and removed Needs: Triage 🔍 labels Mar 14, 2022
@fabiofranzini
Copy link
Collaborator

Hi @DJoshi23 and @joelfmrodrigues, I tried by using the latest public version of the library (3.7.2) and for me the result is this one (using a SPFx 1.14.0 solution with a standard Web Part deployed as a Teams Tab):

PlaceholderInTeamsTab

So, my advice is to update both this library and the whole SPFx project to the latest version.

However, the classic problem remains, namely the fact that a solution deployed in this way loses some styles such as the font and the real Teams theme applied (a problem that has been well known for a long time).

@joelfmrodrigues what do you think? Is it time for a check to manage the Fluent theme if you are within Teams? Some kind of
ThemeProvider that applies the Teams theme automatically if you are in Teams and systems finally the question of fonts?
I had already scheduled this type of control since the problem is common.

In this case I can work on a check like that 🙂

@joelfmrodrigues
Copy link
Collaborator

@fabiofranzini are you referring to a control/helper that would be responsible for the theme on it's own and could be used with any other control to address the issue?

@fabiofranzini
Copy link
Collaborator

@fabiofranzini are you referring to a control/helper that would be responsible for the theme on it's own and could be used with any other control to address the issue?

Exactly! The same problem exists for the isolated web parts, it could be solved in this way, by wrapping the controls to be used as children of this "new control". This solves the problem universally, even for all fluent controls.

@joelfmrodrigues
Copy link
Collaborator

Yup, that would be amazing to have 🙂 it's definitely one of the pain points with SPFx in my opinion as it's always complex to handle and test across all scenarios.
I will assign this issue to you 🙂 Many thanks!

@joelfmrodrigues joelfmrodrigues added area:new-control status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. and removed help wanted Good First Issue 🏆 labels Apr 26, 2022
@fabiofranzini
Copy link
Collaborator

Ok, there are two things.
One is the new control we mentioned, I've already done some tests.

The problem described by @DJoshi23 remains, even if I pass him a correct theme it seems that the PlaceHolder control does not work correctly as he has written, so I need to modify it.

I will work on it and update you.

@fabiofranzini
Copy link
Collaborator

First implementation done:

EnhancedThemeProvider

As you can see, the theme colors are applied based on the selected Teams theme, the same thing for fonts too.
The problem with Placeholder control (and many others) is that they don't have direct Themes support.

@joelfmrodrigues do you prefer that we leave this issue for the Placeholder control and create a new one for the new control I called "EnhancedThemeProvider"?

@fabiofranzini
Copy link
Collaborator

Ok, I checked the code of the Placeholder control and I realized that sass was used for the style part.
This ensures that the style change is not applied until the page is reloaded, and in fact the behavior is just that. What is best done is:

  • add the 'theme' property to the control`s properties
  • rewrite the sass part using @fluentui/merge-styles
  • use the theme property correcly

@joelfmrodrigues If you tell me it's ok, I can start tweaking the control

@fabiofranzini
Copy link
Collaborator

Here is an early version

EnhancedPlaceholder

@joelfmrodrigues
Copy link
Collaborator

@fabiofranzini sorry for the late reply...
It's looking great! 👏

@fabiofranzini
Copy link
Collaborator

Ok, I've finished updating the code to support the themes and theme variations of the sections in the Placeholder control and I'm ready to do the PR.

Now, the problem raised by this issue remains, that is, if you set the Teams theme as High Contrast, the result remains the one shown by @DJoshi23.

This is because using SPFx in Teams, Teams using a SharePoint page under the hood that has a theme applied that mimics that of Teams but isn't.

The reason is simple, Teams uses a UI framework which is Fluent React NorthStar instead SPFx uses Fluent UI React.
Two different frameworks that have a completely different theme system.
Now, the theme that Microsoft implemented in SharePoint to mimic Teams Hight Contrast is not done well, which is why it looks so bad when use it.

So how to solve the problem of this issue:

  1. give support to the issues to the Placeholder component
  2. create a component that mimics the Teams themes as much as possible and pass them on to the child components

The first point is made while for the second I am working on it.
If you agree, do this:

  1. create an issue and then send the PR for the Placeholder check
  2. create an issue and then send the PR for the control that I called EnhancedThemeProvider which gives support to Teams themes in Fluent UI.
  3. close this issue by explaining how to combine the two controls to solve the problem.

What do you thinks @joelfmrodrigues?

@joelfmrodrigues
Copy link
Collaborator

@DJoshi23 this has now been fixed by @fabiofranzini and the PR was merged to the dev branch. You can get the updates if you install the beta version and if you do give it a try, please let us know if you find any issues. It looks great so far 👏

@joelfmrodrigues joelfmrodrigues added status:fixed-next-drop Issue will be fixed in upcoming release. and removed status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. labels Apr 28, 2022
@joelfmrodrigues joelfmrodrigues added this to the 3.8.0 milestone Apr 28, 2022
@fabiofranzini
Copy link
Collaborator

@joelfmrodrigues @DJoshi23 the problem is not completely resolved because the Hight Contrast theme in SPFx is not equal to the Hight Contrast theme in Teams...

I'm working on another control (something like EnhancedThemeProvider as a component that mimics the Teams themes as much as possible and pass them on to the child components) and will be available soon. 😀

@joelfmrodrigues
Copy link
Collaborator

Ups, sorry for my confusion and thanks for clarifying @fabiofranzini

@joelfmrodrigues joelfmrodrigues added status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. and removed status:fixed-next-drop Issue will be fixed in upcoming release. labels Apr 29, 2022
@joelfmrodrigues joelfmrodrigues removed this from the 3.8.0 milestone Apr 29, 2022
@fabiofranzini
Copy link
Collaborator

Hi all, just an update: #1202 (comment)

@michaelmaillot
Copy link
Collaborator

Hi @DJoshi23,

Following amazing work done by @fabiofranzini, did you had the chance to retry with the EnhancedThemeProvider which is available since 3.9.0?

@ghost
Copy link

ghost commented Aug 28, 2023

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within next 7 days of this comment. Thank you for your contributions to SharePoint Developer activities.

@ghost ghost closed this as completed Sep 4, 2023
@ghost
Copy link

ghost commented Sep 4, 2023

Closing issue due no response from original author. If this issue is still occurring, please open a new issue with additional details. Notice that if you have included another related issue as additional comment on this, please open that also as separate issue, so that we can track it independently.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:new-control Needs: Author Feedback no-recent-activity status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. type:enhancement New feature or enhancement of existing capability
Projects
None yet
Development

No branches or pull requests

4 participants