Skip to content

Commit 04c0002

Browse files
authored
Merge pull request #7785 from LazyClicks/main
fix: Alt + click not working on windows and mac
1 parent 308f792 commit 04c0002

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

.changeset/thirty-monkeys-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik': patch
3+
---
4+
5+
FIX: fix up open in editor feature

packages/qwik/src/optimizer/src/plugins/click-to-component.html

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
cursor: pointer;
1111
z-index: 999999;
1212
}
13+
1314
#qwik-inspector-info-popup {
1415
position: fixed;
1516
bottom: 10px;
@@ -28,13 +29,16 @@
2829
z-index: 999999;
2930
contain: layout;
3031
}
32+
3133
#qwik-inspector-info-popup p {
3234
margin: 0px;
3335
}
36+
3437
@-webkit-keyframes fadeOut {
3538
0% {
3639
opacity: 1;
3740
}
41+
3842
100% {
3943
opacity: 0;
4044
}
@@ -44,6 +48,7 @@
4448
0% {
4549
opacity: 1;
4650
}
51+
4752
100% {
4853
opacity: 0;
4954
visibility: hidden;
@@ -145,14 +150,23 @@
145150
globalThis.qwikOpenInEditor = function (path) {
146151
const isWindows = navigator.platform.includes('Win');
147152
const resolvedURL = new URL(path, isWindows ? origin : srcDir);
148-
if (resolvedURL.origin === origin) {
149-
const params = new URLSearchParams();
150-
const prefix = isWindows ? srcDir : '';
151-
params.set('file', prefix + resolvedURL.pathname);
152-
fetch('/__open-in-editor?' + params.toString());
153+
const prefix = isWindows ? srcDir : srcDir.replace('http://local.local', '');
154+
const params = new URLSearchParams();
155+
const filePath =
156+
resolvedURL.protocol === 'file:' && resolvedURL.pathname.startsWith('/')
157+
? resolvedURL.pathname.slice(1)
158+
: resolvedURL.pathname;
159+
let finalPath;
160+
if (filePath.startsWith(prefix)) {
161+
finalPath = filePath;
153162
} else {
154-
location.href = resolvedURL.href;
163+
// remove the extra src from filePath as prefix already contains it
164+
const cleaned = filePath.replace(/^[/\\]?src[/\\]/, '');
165+
const sep = isWindows ? '\\' : '/';
166+
finalPath = prefix.endsWith(sep) ? prefix + cleaned : prefix + sep + cleaned;
155167
}
168+
params.set('file', finalPath);
169+
fetch('/__open-in-editor?' + params.toString());
156170
};
157171
document.addEventListener(
158172
'contextmenu',

0 commit comments

Comments
 (0)