Skip to content

Commit e183b62

Browse files
committed
Fixed editor tabs so they are interactive again after broken but a big in a recent version of macOS. It seems like the topmost item loses interactivity so we fix this by placing a 1pt Rectangle at the top.
1 parent 1f6c33a commit e183b62

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

CodeEdit/Features/Editor/TabBar/Tabs/Tab/EditorTabView.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ struct EditorTabView: View {
226226
}
227227
}
228228
)
229-
// This padding is to avoid background color overlapping with top divider.
230-
.padding(.top, 1)
231229
.zIndex(isActive ? 2 : (isDragging ? 3 : (isPressing ? 1 : 0)))
232230
.id(item.id)
233231
.tabBarContextMenu(item: item, isTemporary: isTemporary)

CodeEdit/Features/Editor/TabBar/Views/EditorTabBarView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
import SwiftUI
99

1010
struct EditorTabBarView: View {
11+
let hasTopInsets: Bool
1112
/// The height of tab bar.
1213
/// I am not making it a private variable because it may need to be used in outside views.
1314
static let height = 28.0
1415

1516
var body: some View {
1617
HStack(alignment: .center, spacing: 0) {
1718
EditorTabBarLeadingAccessories()
19+
.padding(.top, hasTopInsets ? -1 : 0)
1820
EditorTabs()
1921
.accessibilityElement(children: .contain)
2022
.accessibilityLabel("Tab Bar")
2123
.accessibilityIdentifier("TabBar")
2224
EditorTabBarTrailingAccessories()
25+
.padding(.top, hasTopInsets ? -1 : 0)
2326
}
2427
.frame(height: EditorTabBarView.height)
2528
.padding(.leading, -1)

CodeEdit/Features/Editor/Views/EditorAreaView.swift

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,38 @@ struct EditorAreaView: View {
9494
.frame(maxWidth: .infinity, maxHeight: .infinity)
9595
.ignoresSafeArea(.all)
9696
.safeAreaInset(edge: .top, spacing: 0) {
97-
VStack(spacing: 0) {
98-
if shouldShowTabBar {
99-
EditorTabBarView()
100-
.id("TabBarView" + editor.id.uuidString)
101-
.environmentObject(editor)
102-
Divider()
103-
}
104-
if showEditorJumpBar {
105-
EditorJumpBarView(
106-
file: editor.selectedTab?.file,
107-
shouldShowTabBar: shouldShowTabBar
108-
) { [weak editor] newFile in
109-
if let file = editor?.selectedTab, let index = editor?.tabs.firstIndex(of: file) {
110-
editor?.openTab(file: newFile, at: index)
97+
GeometryReader { geometry in
98+
let topSafeArea = geometry.safeAreaInsets.top
99+
VStack(spacing: 0) {
100+
if topSafeArea > 0 {
101+
Rectangle()
102+
.fill(.clear)
103+
.frame(height: 1)
104+
.background(.clear)
105+
}
106+
if shouldShowTabBar {
107+
EditorTabBarView(hasTopInsets: topSafeArea > 0)
108+
.id("TabBarView" + editor.id.uuidString)
109+
.environmentObject(editor)
110+
Divider()
111+
}
112+
if showEditorJumpBar {
113+
EditorJumpBarView(
114+
file: editor.selectedTab?.file,
115+
shouldShowTabBar: shouldShowTabBar
116+
) { [weak editor] newFile in
117+
if let file = editor?.selectedTab, let index = editor?.tabs.firstIndex(of: file) {
118+
editor?.openTab(file: newFile, at: index)
119+
}
111120
}
121+
.environmentObject(editor)
122+
.padding(.top, shouldShowTabBar ? -1 : 0)
123+
Divider()
112124
}
113-
.environmentObject(editor)
114-
.padding(.top, shouldShowTabBar ? -1 : 0)
115-
Divider()
116125
}
126+
.environment(\.isActiveEditor, editor == editorManager.activeEditor)
127+
.background(EffectView(.headerView))
117128
}
118-
.environment(\.isActiveEditor, editor == editorManager.activeEditor)
119-
.background(EffectView(.headerView))
120129
}
121130
.focused($focus, equals: editor)
122131
// Fixing this is causing a malloc exception when a file is edited & closed. See #1886

0 commit comments

Comments
 (0)