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

Selectbox theme additions Fixes #25965, #35246, #25700, #21193 #37533

Merged
merged 15 commits into from
Dec 18, 2017

Conversation

cleidigh
Copy link
Contributor

@cleidigh cleidigh commented Nov 2, 2017

Selectbox theme additions Fixes #25965, #35246, #25700, #25619, #21193

I fixed all the issues I have found as well as addressing a lot of aesthetic issues.

Vertical margins addressed
Horizontal margins - controlled by ContextV - only flips when window edge hit
Could address this with optional margin requirements passed to ContextV (your call)
Cannot use CSS or forced resize because it conflicts with ContextV logic
Added VerticalScrollBar visibility option to listview - could also add horizontal
Tweaked margins for high contrast mode
DropDown is fully modal - could pass through other keyboard commands if desired
Re-Tested non-native select mode on : Windows 7, OS X, Debian
As first list/ContextV effort , make sure I didn't miss use anything !

See prior PR for more discussion #36193

@cleidigh cleidigh changed the title Selectbox theme additions Fixes #25965, #35246, #25700 (replaces #36193 Selectbox theme additions Fixes #25965, #35246, #25700 (replaces #36193) Nov 2, 2017
@bpasero bpasero self-assigned this Nov 2, 2017
@bpasero bpasero added this to the November 2017 milestone Nov 2, 2017
@bpasero
Copy link
Member

bpasero commented Nov 3, 2017

@cleidigh good progress.

Colors
I am not so happy with the colors that are used yet:

  • light theme: the active option shows in blue but then I would turn the foreground color of the text to white (same as we do in explorer). also, when I hover over the active option, the blue is removed and I am almost not seeing the slight hover feedback that shows up. also, we should probably use our default focus color (blue) for the border of the dropdown:
    image
  • dark theme: same issue with loosing the blue of the active option once I hover

Accessibility:

  • when I press Space on the focused select widget, I would expect the element to expand and show all options.
  • when I arrow up and down through the options, a screen reader is not reading out the elements

@cleidigh
Copy link
Contributor Author

cleidigh commented Nov 6, 2017

@bpasero

Addressed all comments, but a couple of questions/comments.

Theme colors:

  • Fixed registered colors to use white foreground color for light/dark themes, exceptions noted below.
  • Tweaked hover background for select dd on light themes (normal list color has basically zero contrast)
  • Did NOT change normal list colors - not sure if this is one of the things you referenced, exists currently.

Hover background behavior:

  • hover color now supersedes select background colors
  • I think this is what you mention your comments HOWEVER this is not the current behavior for list/quick open et cetera
  • If I misinterpreted your comment, let me know and I will restore

Abyss

  • Match list colors

Dark (VSC)

  • Set foreground color to white
  • Match focus border color

Dark+ (default dark)

  • Set foreground color to white
  • Match focus border color

High Contrast

  • Scaled outline styles
  • Slightly increased padding to make outlines more visible

Kimbie Dark

  • Match list colors

Light (VSC)

  • Set foreground color to white
  • Match focus border color
  • Increase hover contrast
    "dropdown.optionHoverBackground": "#e4e4e4"

Light (default light)

  • Set foreground color to white
  • Match focus border color
  • Increase hover contrast
    "dropdown.optionHoverBackground": "#e4e4e4"

Monokai

  • Match list colors

Monokai Dimmed

  • Match list colors
  • NOTE: The colors for active selection, focus, hover are all the same giving zero Contrast
  • Should these be changed?

Quiet Light

  • Match list colors
  • Match focus border color
  • Set foreground color to main foreground color (white not enough contrast)
    "dropdown.optiooverBackground": "#e4e4e4"

Red

  • Match list colors

Solarized Light

  • Match list colors

Solarized Dark

  • Match list colors

Tomorrow Night Blue

  • Match list colors

Accessibility/Behaviors:

  • Added ARIA labels for select options

  • Installed NVDA - You should see Dragon arguing with the screen reader ;-) !

  • Seems to read off labels okay

  • Select dropdown expand with Space - just figured out you meant for native mode

  • I restored original, native drop down with Space (non-native had already)

  • Added Enter expansion as well - as in original

Saludos

@bpasero bpasero modified the milestones: November 2017, On Deck Nov 6, 2017
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

@cleidigh gave a bit of feedback on the change.

I think to make this PR easier to review I suggest to split the native select box and the custom one into one file each and use it depending on the OS.

I also question why we have to introduce so many new colors. I think all colors we need are already there via the list/tree colors and should be reused so that all our themes do not have to adopt this.

I still see some bugs:

  • hovering over an item that is selected should not remove that selection color
    image
  • the dropdown cannot be used from the debug toolbar. you can reproduce by launching multiple programs from one window:
    image
  • you cannot click on the scrollbar to scroll, it will actually close the dropdown

@@ -430,9 +431,10 @@ export class SwitchTerminalInstanceActionItem extends SelectActionItem {
constructor(
action: IAction,
@ITerminalService private terminalService: ITerminalService,
@IThemeService themeService: IThemeService
@IThemeService themeService: IThemeService,
@IContextViewService private contextViewService: IContextViewService
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh remove private here to fix the warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -108,9 +109,10 @@ export class SwitchOutputActionItem extends SelectActionItem {
constructor(
action: IAction,
@IOutputService private outputService: IOutputService,
@IThemeService themeService: IThemeService
@IThemeService themeService: IThemeService,
@IContextViewService private contextViewService: IContextViewService
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh remove private here to fix the warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -184,9 +186,10 @@ export class FocusProcessActionItem extends SelectActionItem {
constructor(
action: IAction,
@IDebugService private debugService: IDebugService,
@IThemeService themeService: IThemeService
@IThemeService themeService: IThemeService,
@IContextViewService private contextViewService: IContextViewService
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh remove private here to fix the warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -40,10 +41,11 @@ export class StartDebugActionItem implements IActionItem {
@IDebugService private debugService: IDebugService,
@IThemeService private themeService: IThemeService,
@IConfigurationService private configurationService: IConfigurationService,
@ICommandService private commandService: ICommandService
@ICommandService private commandService: ICommandService,
@IContextViewService private contextViewService: IContextViewService,
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh remove private here to fix the warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Is this new warning? I don't think I saw this before.

Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh yes we added lots of more warning support recently by adopting TSLint 5

@@ -183,6 +183,11 @@ export const inputValidationErrorBorder = registerColor('inputValidation.errorBo
export const selectBackground = registerColor('dropdown.background', { dark: '#3C3C3C', light: Color.white, hc: Color.black }, nls.localize('dropdownBackground', "Dropdown background."));
export const selectForeground = registerColor('dropdown.foreground', { dark: '#F0F0F0', light: null, hc: Color.white }, nls.localize('dropdownForeground', "Dropdown foreground."));
export const selectBorder = registerColor('dropdown.border', { dark: selectBackground, light: '#CECECE', hc: contrastBorder }, nls.localize('dropdownBorder', "Dropdown border."));
export const selectOptionCheckedForeground = registerColor('dropdown.optionCheckedForeground', { dark: Color.white, light: Color.white, hc: null }, nls.localize('dropdownOptionCheckedForground', "Dropdown option checked foreground."));
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh suggest to make the description more descriptive and use a different name than "option" which is very HTML specific. E.g. to align with existing colors we already have for the tree:

dropdown.optionCheckedForeground

  • rename to dropdown.selectionForeground
  • description: Foreground color of the selected item in the dropdown.

dropdown.optionCheckedBackground

  • rename to dropdown.selectionBackground
  • description: Background color of the selected item in the dropdown.

dropdown.optionHoverForeground

  • rename to dropdown.hoverForeground
  • description: Foreground color of items in the dropdown when hovering over.

dropdown.optionHoverBackground

  • rename to dropdown.hoverBackground
  • description: Background color of items in the dropdown when hovering over.

Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh actually thinking more about it, why do we have these colors at all? can we not just use the tree colors? since we are already using the same widget I see no much value in having different colors only for the dropdown....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using list colors.

this.widthControlElement.className = 'option-text-width-control';
dom.append(widthControlInnerDiv, this.widthControlElement);
// this.widthControDivElement = widthControlInnerDiv;
// TODO:cleidigh - find better width control
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh can you fix or remove this TODO?

if (!this._useNativeSelect) {

if (this.styles.selectOptionCheckedBackground) {
content.push(`.monaco-shell .select-dropdown-container .selectbox-dropdown-list-container .monaco-list .monaco-list-row.focused:not(:hover) { background-color: ${this.styles.selectOptionCheckedBackground} !important; }`);
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh again please express the DOM hierarchy if possible, e.g. .select-dropdown-container .selectbox-dropdown-list-container => .select-dropdown-container > .selectbox-dropdown-list-container

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if (this.options[index].length > this.options[longest].length) {
longest = index;
}
};
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh extra comma to remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


this.toDispose.push(dom.addDisposableListener(this.selectElement, dom.EventType.CLICK, () => {
this.showSelectDropDown();
event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh I suggest to use the shorter stop function with the option to cancel bubble.

return elementWidth;
}

public cloneElementFont(source: HTMLElement, target: HTMLElement) {
Copy link
Member

Choose a reason for hiding this comment

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

@cleidigh not so happy:

  • why is the method public?
  • it uses var, which we try to avoid (e.g. use let or const instead)
  • can the value be cached and reused instead of always asking for it?

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 7, 2017

@bpasero
Thanks for the review comments. I will work on these as fast as I can today.
Not sure about the cleanest way to split the class across files. I will investigate/question if necessary.

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 8, 2017

Selection color precedence over hover:

I had understood the opposite before, my bad...
Fixed.

Loss a focus clicking scrollbar:

Had to detect clicks on scrollbar versus items.
Fixed.

@bpasero
Copy link
Member

bpasero commented Dec 8, 2017

@cleidigh awesome. take your time, I think with the stuff addressed we can merge this in for December milestone.

Splitting the custom part out of the native one makes it easier for me to review the change. Now it is very hard to understand the impact for the native implementation. I think stuff will be cleaner when the two implementations are separated.

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 8, 2017

@bpasero
I basically have two things left to deal with, colors and file separation.
I originally ran into some problems trying to just use the list colors, I will see if I still have problems.

For the class separation: I am looking into possible design patterns and want your input before I cut things up.

Most basic:

  • Keep Main widget methods (render, layout, style etc) in selectBox class/file
  • Have these call equivalent methods in each of the native and list files

Mixin Methods:

  • Create classes/files with mixing from native and list classes/files
  • Use applyMixins function to mixed methods from appropriate selectbox type per OS
  • Must have placeholder methods in the main select box file
  • Cleaner since does not require if/else for every method to call the sub methods

Preference or other option?

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 8, 2017

@bpasero
December sounds good, I knew it was getting too close for November.

I have one other problem - I am trying to see the problem with the debug drop-down.
I cannot get code OSS to do Debug, says cannot to node or Chrome.
is this disabled code OSS? if so any workaround?

@bpasero
Copy link
Member

bpasero commented Dec 8, 2017

@cleidigh yeah here is how to do it:

  • in the code-oss instance pick the command "Extensions: Open Extensions Folder" from commands picker
  • open another finder/explorer in the OS and navigate to the extensions folder of your installed VS Code (we ship debug as built in extension so it is part of the installation)
  • copy the following folders over to the code-oss folder that you opened before: ms-vscode.node-debug, ms-vscode.node-debug2
  • reload code-oss window and it should work fine

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 8, 2017

Cool I will try that.

Any preference on the separation approach?

@bpasero
Copy link
Member

bpasero commented Dec 8, 2017

@cleidigh well maybe the selectBox.ts could wrap around a ISelectBox interface that is implemented both for custom and for native. These two implementations can live next to each other in separate files. Within the constructor of selectBox.ts we do the check for the platform and then instantiate either the one or the other. But throughout the rest of the file we only talk to the interface.

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 8, 2017

@bpasero
I think we are close, but if I just do an interface without the mixing I don't think I can have
method overrides for the widget functions which I believe are expected to be included
in the main select box class. if I do mixing overrides I can get it to work although there is still a couple approaches to this as well.

@bpasero
Copy link
Member

bpasero commented Dec 8, 2017

@cleidigh I think it would work with an interface. basically you are delegating the calls to selectBox.ts into the implementation through the interface. So depending on which implementation is enabled it will reach either native or custom implementation.

@cleidigh
Copy link
Contributor Author

@bpasero
I have most things fixed.
I cannot get Code OSS to do debugging to test the problem with the debugger widget.
I did not have the debug extension folders, I think they are integrated.
I had to clone and build the two debugger extensions. I think that worked they seem to be loaded.
Cannot launch a debug session I get a connection error.
Also tried to package OSS thinking that might be more direct, packaging builds okay but does not run ,two processes are started but nothing appears on screen.
I am at a loss to continue.

@bpasero
Copy link
Member

bpasero commented Dec 11, 2017

@cleidigh maybe easier if you try to debug an extension because everything is setup for you there. Just:

  • npm install -g yo
  • npm install -g generator-code
  • yo code
  • pick the JS extension
  • do this two times to have multiple debug targets
  • open both extensions in one window
  • run both from the debug viewlet

You should get the debug toolbar with a dropdown.

@cleidigh
Copy link
Contributor Author

@bpasero
Thanks that worked. Looks like it works I got the drop down, maybe it was a merge issue.
I will commit and post when I have everything the separation done just to have some work in progress
before I re- factor everything.

@cleidigh
Copy link
Contributor Author

cleidigh commented Dec 13, 2017

@bpasero
I believe I have addressed all your issues. To use your expression, I am not "happy" with the separation
approach, but after trying a variety of other ways including decorators and mixins , this seemed to be the best way.

Everything should be pretty clean now, I now use all list colors and passed focusBorder directly into
SelectBoxStyles.

FYI: Several themes have little to no contrast for the list select and list hover. These include Monokai
Dimmed and the light themes. Let me know if you agree and I will fix.

Hopefully it looks good to you...

@cleidigh cleidigh changed the title Selectbox theme additions Fixes #25965, #35246, #25700 (replaces #36193) Selectbox theme additions Fixes #25965, #35246, #25700, #21193 Dec 13, 2017
@bpasero bpasero modified the milestones: On Deck, December 2017/January 2018 Dec 14, 2017
@cleidigh
Copy link
Contributor Author

Missed a couple things 👎

  • var -> let
  • duplicated listener

@bpasero
Copy link
Member

bpasero commented Dec 18, 2017

@cleidigh fyi did some last polish via 6f14fd3

  • properly hooked up the dispose method to the delegate
  • separated CSS according to implementations
  • removed some unnecessary null checks for the delegate

@bpasero bpasero merged commit 9a5b6eb into microsoft:master Dec 18, 2017
@bpasero
Copy link
Member

bpasero commented Dec 18, 2017

@cleidigh thanks for the work here 👍

@cleidigh
Copy link
Contributor Author

@bpasero
Excellent ! Very glad this could get merged ;-) Will address #40438 ASAP
I reviewed your polish to learn and understand. For my edification -

  • I see you want to do the disposal within the class not the client - I assume this is the normal approach.
  • Did you remove the null checks because all code paths essentially guarantee SelectBoxIDelegate is set?

I appreciate you working with me on this for all this time. Really learned a lot for future contributions !
Cheers

@cleidigh cleidigh deleted the selectbox-dd/add branch December 18, 2017 17:25
@bpasero
Copy link
Member

bpasero commented Dec 19, 2017

@cleidigh ah yeah I did not see that the disposal thing was passed over. I think I still prefer the style where the disposing is passed on to the child element, that is what we typically do in other places.

And yeah, the SelectBoxIDelegate can never be null so removing some code that would never get triggered.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI Theme Add: select-box(drop downs) selection and hover colors
2 participants