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

Instructure UI components inside of Canvas #1439

Closed
AustinKP opened this issue Feb 12, 2024 · 6 comments
Closed

Instructure UI components inside of Canvas #1439

AustinKP opened this issue Feb 12, 2024 · 6 comments
Assignees

Comments

@AustinKP
Copy link

AustinKP commented Feb 12, 2024

Question

Is it possible to use instructure's UI react components within instructure's canvas itself? I'm trying to build a custom module that hooks into canvas but uses some of the existing canvas components from this library in my custom module if possible but I receive this error:

image

Note: I actually am able to see the components render but I'm receiving a ton of that error above

@HerrTopi
Copy link
Contributor

Hi! Could you provide more information on what you are trying to achieve and with what code?

@HerrTopi HerrTopi self-assigned this Feb 13, 2024
@AustinKP
Copy link
Author

AustinKP commented Feb 13, 2024

@HerrTopi Hey there! Basically, we have custom JS that hooks into canvas to provide custom functionality. The goal is to use some of the components from this library in our custom code. I'm just wrapping our App component with the provider as mentioned in the documentation and then I have a button component from this library. While this does render correctly our console is full of max call stack errors. I'm curious if anyone has used any of these components within canvas itself (custom module)

@OrchidForever
Copy link

@HerrTopi Happy Wednesday!

I looked into the issue more with @AustinKP and it looks like the issue with the package ui-dom-utils. Pointedly one function in particular, getComputedStyle.

Our react code is injected into canvas and cavas-lms uses jQuery who calls on the Window object getComputedStyle. The function from from this file getComputedStyle.ts is picked up instead. This causes a huge loop within the webpage.

I'm not sure 100% what the correct solution would be as I don't know the history of why some of the utils in ui-dom-utils exists.

I had tried locally modifying the code in the repo and just removing getComputedStyle.ts and changing the references to Window.prototype.getComputedStyle and it worked in a very limited test. But so far in canvas, this seemed to be the only function jQuery didn't play well with.

@matyasf
Copy link
Collaborator

matyasf commented May 23, 2024

hi!
Sorry for the late reply.

I'm pretty sure that InstUI will break if you remove its getComputedStyle function. Its really strange that this function is picked up instead, we do not put it on the window object. We do not put anything on global objects like window, I have checked for getComputedStyle and we're not doing this.

I have 2 guesses:

  1. Some build tooling is messing it up when you compile your app.
  2. There is some code in your part that puts this to the window object

@balzss
Copy link
Contributor

balzss commented Jul 4, 2024

@AustinKP @OrchidForever do you have any updates on this? were you able to solve this and if not, is this still relevant? thanks

@balzss
Copy link
Contributor

balzss commented Aug 14, 2024

closing this for now. feel free to reopen if still relevant

@balzss balzss closed this as completed Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants