@lvce-editor/activity-bar-worker 1.27.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1144,10 +1144,30 @@ const handleBlur = state => {
|
|
|
1144
1144
|
};
|
|
1145
1145
|
};
|
|
1146
1146
|
|
|
1147
|
-
const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount) => {
|
|
1147
|
+
const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height) => {
|
|
1148
|
+
if (itemCount === 0) {
|
|
1149
|
+
return -1;
|
|
1150
|
+
}
|
|
1151
|
+
// If there's only one item, treat it as a top item (not Settings at bottom)
|
|
1152
|
+
if (itemCount === 1) {
|
|
1153
|
+
const relativeY = eventY - y;
|
|
1154
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
1155
|
+
if (index < 0 || index >= itemCount) {
|
|
1156
|
+
return -1;
|
|
1157
|
+
}
|
|
1158
|
+
return index;
|
|
1159
|
+
}
|
|
1160
|
+
// Settings is always at the bottom (last item) when there are multiple items
|
|
1161
|
+
const settingsBottomY = y + height;
|
|
1162
|
+
const settingsTopY = settingsBottomY - itemHeight;
|
|
1163
|
+
// Check if click is in the Settings area (bottom)
|
|
1164
|
+
if (eventY >= settingsTopY && eventY < settingsBottomY) {
|
|
1165
|
+
return itemCount - 1;
|
|
1166
|
+
}
|
|
1167
|
+
// Otherwise, calculate index from top items
|
|
1148
1168
|
const relativeY = eventY - y;
|
|
1149
1169
|
const index = Math.floor(relativeY / itemHeight);
|
|
1150
|
-
if (index < 0 || index >= itemCount) {
|
|
1170
|
+
if (index < 0 || index >= itemCount - 1) {
|
|
1151
1171
|
return -1;
|
|
1152
1172
|
}
|
|
1153
1173
|
return index;
|
|
@@ -1222,9 +1242,10 @@ const handleClick = async (state, button, eventX, eventY) => {
|
|
|
1222
1242
|
const {
|
|
1223
1243
|
filteredItems,
|
|
1224
1244
|
itemHeight,
|
|
1225
|
-
y
|
|
1245
|
+
y,
|
|
1246
|
+
height
|
|
1226
1247
|
} = state;
|
|
1227
|
-
const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length);
|
|
1248
|
+
const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length, height);
|
|
1228
1249
|
return handleClickIndex(state, button, index, eventX, eventY);
|
|
1229
1250
|
};
|
|
1230
1251
|
|