-
Notifications
You must be signed in to change notification settings - Fork 16
FIREFLY-1744: Fix ADQL color mode bug in Job Monitor dialog #1902
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
base: dev
Are you sure you want to change the base?
Conversation
jaladh-singhal
left a comment
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.
Tested! Working as expected.
I think it's good as an intermediate fix/workaround.
| <ListBoxInputFieldView {...{ | ||
| onChange: (ev, newValue) => { | ||
| setMode(newValue); | ||
| DialogRootContainer.refreshDialogs();//forces a re-render of open dialogs to update their color mode |
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.
I wonder if it's possible to directly pass this color mode (newValue) to dialog root here (like setMode/useMode does for firefly root) which would have prevented reading scheme from DOM.
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.
@jaladh-singhal I made a new commit that sort of follows this feedback. Can you take a look? I do think it's cleaner (I'll get rid of the commented out code if we decide to keep this change):
- essentially,
refreshDialogs(newValue)forces the dialog root to re-render. - The key in FireflyRoot (in reRender) forces a remount of FireflyRoot in the dialog root (which was previously missing, only the main (non-dialog) FireflyRoot was re-rendering, which is why
useColorModeinsideCssStrThemeWrapperwould not give the right value for dialogs).- with this change, we don't need to make any changes in
PrismADQLAwareorCssStrThemeWrapperat all.
- with this change, we don't need to make any changes in
Let me know what you think.
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.
Thanks for trying it out. It is def cleaner now. About the key, shouldn't that be in DialogRootComponent instead of FireflyRoot? I'm not sure about this though.
8f490b9 to
b933d5d
Compare
| /*const {isDarkMode: isDarkFromJoy} = useColorMode(); | ||
| const scheme = getJoySchemeFromDom(); | ||
| const isDarkFromDom = scheme === 'dark'; | ||
| const isDarkMode = preferDomScheme ? isDarkFromDom : isDarkFromJoy;*/ |
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.
This is a reusable component that supports color mode changes. Without useColorMode, it would stop working entirely, so it can’t be commented out. I’m not sure if it’s related, but TAP → Edit ADQL is now broken.
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 @loitly I am keeping the useColorMode() (it's above this commented out code) because I know CssStrThemeWrapper is used elsewhere (AdvancedADQL). Is Tap -> Edit ADQL broken only on my test build above? or do you see it broken on nightly too? if it's the former, then I'll have to look into it...
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.
Never mind, the bug with ADQL was in my code. Fixed in a new 1 line commit and re-building test build. But rest of what I wrote up here still holds (about useColorMode()).
| * @param p.preferDomScheme | ||
| */ | ||
| export default function CssStrThemeWrapper({cssStr, children, ...props}) { | ||
| export default function CssStrThemeWrapper({cssStr, preferDomScheme=false, children, ...props}) { |
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.
preferDomScheme is no longer in use, I think this whole file can be reverted as well as AdvancedADQL
|
@kpuriIpac your build is no longer accessible to me but I trust your testing 😄 and it's ready to merge after removing dead code imo (esp because it's an intermediate fix) |
Ticket: https://jira.ipac.caltech.edu/browse/FIREFLY-1744
DialogRootContaineris essentially a separate root (from the mainFireflyRoot)AppConfigDrawerandDialogRootContainertake care of this, forcing a re-render of the dialog on theme changeuseColorMode()in CssStrThemeWrapper would still not give the correct theme for the dialog (because dialogs are rendered in a separate React root with their own JoyCssVarsProvider)Eventually, this PR could be made redundant if dialogs were not in a separate React Tree. We plan on discussing this change January 27-28.
Testing:
Firefly: https://fireflydev.ipac.caltech.edu/firefly-1744-adql-toggle-bug/firefly