-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
fix: Apply theme to only to active excalidraw component #3446
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/excalidraw/excalidraw/28wp4vKmj8rM1jALNfe37YEJXtx8 |
Conceptually looks fine. But we should name it |
I am thinking will also expose the |
That will mess up with memoization. I'd make it be just the |
I don't think apart from the focus I was planning to expose anything else and one can directly call |
const isDarkTheme = | ||
!!excalidrawContainer?.classList.contains("theme--dark") || | ||
theme === "dark"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't want to use theme
only (since it's optional), it should nevertheless take precedence since it's explicit, so let's swap the order of checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unclear what you mean, theme is given less precedence since its optional over excal container so why we want to check theme first ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's supplied and for some reason isn't matching the container, we should prefer the explicit value. Is there actually a reason why we're supplying it at all? Aren't Modals always part of the component tree? EDIT: forgot about Collab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I suppose since this isn't public API it doesn't matter, and actually is preferable UX-wise. It'll just mean the app might have slight bugs without us knowing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this isn't public API, if in the future we expose Dialog then it can be helpful for the host but I don't think we will be doing that as the host will always have its own dialogs and since its for excal app itself so I have given preference to excal container over theme.
Make sure theme is only applied to the active Excalidraw component when multiple excalidraw rendered
Exposed a hook that gives access to the current instance, this will be useful when focusing the current instance as well(ex after dialog close, we can expose focus function as well for the same)
Since collab dialog is not in the hierarchy of App.tsx hence had to add a new prop theme so it can be used to add a
theme
to custom dialogs as well.Try here