microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.78k stars 29.11k forks source link

Consolidate zindex for floating elements in the workbench #130217

Open rebornix opened 3 years ago

rebornix commented 3 years ago

Currently in the workbench, we have quite a lot of custom floating elements, e.g., context menu, hover, suggest, which are not native OS controls. To ensure they are above other DOM elements, we usually update z-index but since the workbench grid view is flat, most z-index we use now are universal (not limited to its own container) and we kept seeing floating elements overlap each other in funny ways (for example, suggest widget overlaps with sash, context menu, toolbar, etc).

We can probably introduce some const enums for zindex, which can be used as a guidance for updating zindex in your own component:

const enum ZINDEX {
  Sash = 35,
  SuggestWidget = 40,
  QuickInput= 1000,
  ContextView = 2500,
  ModalDialog = 2600
  ...
}

The list will be short and give us an idea of what range of z-index is safe to use in one particular component.


Current status

bpasero commented 3 years ago

💯

Just to outline the troubles I have only in the editor tabs control:

https://github.com/microsoft/vscode/blob/de6057e397eb2e2bdc45cf20b1b880f040145c6c/src/vs/workbench/browser/parts/editor/media/tabstitlecontrol.css#L6-L35

isidorn commented 3 years ago

@rebornix thanks for doing this. Having a central place where all the z-indexes are listed is a great suggestion, that way when you introduce a new one you can see how it relates to the existing indexes.