Skip to content

High Contrast Fixes #10719

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

Merged
merged 4 commits into from
Jul 1, 2025
Merged

High Contrast Fixes #10719

merged 4 commits into from
Jul 1, 2025

Conversation

thsparks
Copy link
Contributor

This primarily updates areas in pxt where we were checking the old true/false high contrast setting (which is no longer used) instead of the using the new theme manager. It was just an oversight in the theming work. I've created a little static helper function in the theme manager to save some repetitive lines of code.

Separately, it fixes a few places where we were seeing superfluous yellow outlines in hc mode. We have some generic highlighting css logic which, in general, is convenient. But it does seem to be causing some issues too, highlighting things we don't want highlighted. I've special-cased those out for now, but if it becomes a more common occurrence, we may need to rework it more completely.

This fixes one of the issues brought up in microsoft/pxt-microbit#6366 (inconsistent settings), but it does not remove the white background (which was by design). We can decide what we want to do for that separately and follow up in a different change, if needed.

@@ -1275,8 +1270,8 @@ export class ProjectView
return previousEditor ? previousEditor.unloadFileAsync() : Promise.resolve();
})
.then(() => {
let hc = this.getData<boolean>(auth.HIGHCONTRAST)
return this.editor.loadFileAsync(this.editorFile, hc)
let hc = this.themeManager.isHighContrast(this.themeManager.getCurrentColorTheme()?.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't these instances using isCurrentThemeHighContrast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because we already had the theme manager in this file, this is slightly more efficient (if uglier)

@@ -3892,7 +3887,7 @@ export class ProjectView
return (!!debugging != simulator.driver.isDebug()) || (!!tracing != simulator.driver.isTracing())
}

stopSimulator(unload?: boolean, opts?: pxt.editor.SimulatorStartOptions) {
stopSimulator(unload?: boolean, opts?: pxt.editor.SimulatorStartOptions): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change this to a promise, do we need to await this being called in other areas? I see you changed it in onThemeChanged, but are the other places it's called okay with not await-ing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be okay in other areas. I only added the return because of the specific off-then-on again scenario, where I need to actually wait until it is for-sure done setting sim state to "off" before trying to turn it on again. TBH I don't know how it was working without this, but I was able to see the race fairly clearly in my debugging.

In other places, they weren't waiting for that state to finish updating before this change, and they still aren't waiting for it now, so it shouldn't result in any change in behavior (and I didn't want to expand the scope of the change by trying to update them)

@@ -322,7 +323,7 @@ export class SettingsMenu extends data.Component<SettingsMenuProps, SettingsMenu

renderCore() {
const hasIdentity = pxt.auth.hasIdentity();
const highContrast = this.getData<boolean>(auth.HIGHCONTRAST)
const highContrast = ThemeManager.isCurrentThemeHighContrast(document);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the container need the document passed in while the other instances are okay with the default document?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it actually isn't necessary. This is the same as the default. I can remove it.

@@ -632,6 +632,7 @@ export class Toolbox extends data.Component<ToolboxProps, ToolboxState> {
}
<div className="blocklyTreeRoot">
<div
className="blocklyTreeInner"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of changes in here for the keyboard nav stuff, will adding this classname back in possibly mess with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't cause any problems, since it's a new class and only being used in the one place I added it.

Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thsparks thsparks merged commit 9fbeae7 into master Jul 1, 2025
20 checks passed
@thsparks thsparks deleted the thsparks/hc_fixes branch July 1, 2025 17:53
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

Successfully merging this pull request may close these issues.

2 participants