FIREFLY-1744: Fix ADQL color mode bug in Job Monitor dialog #1902
FIREFLY-1744: Fix ADQL color mode bug in Job Monitor dialog #1902
Conversation
jaladh-singhal
left a comment
There was a problem hiding this comment.
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.
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.
@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.
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.
There was a problem hiding this comment.
Yes I think it needs be inside FireflyRoot because really the CssVarsProvider inside FireflyRoot is what needs to remount/re-render..for us to get the correct value from useColorMode (in CssStrThemeWrapper). I did try putting the key in DialogRootComponent, though, and that did not work...I'm guessing for this reason.
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.
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.
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.
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.
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) |
okay thank you for looking at it again! I'm rebuilding the test build after cleanup and will merge then if I find no issues. And yes I agree this is at best an intermediate fix, the good thing is that the |
5f04c8a to
88ea167
Compare
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