Jelmerro / Vieb

Vim Inspired Electron Browser - Vim bindings for the web by design
https://vieb.dev
GNU General Public License v3.0
1.29k stars 61 forks source link

Nextjs onClick won't work #527

Open dennis0324 opened 8 months ago

dennis0324 commented 8 months ago

Checklist

Describe the bug Nextjs onClick eventhandler won't fire

To Reproduce

# used typescript, app-router
$ npx next-create-app
//app/page.tsx
import Test from "./testing";

export default function Home() {
  return (
    <main>
      <Test />
    </main>
  );
}
//app/testing.tsx
"use client";
function Test() {
  return <a onClick={() => console.log("testing")}>test</a>;
}

export default Test;
$ npm run dev

folder tree looked like image

Expected behavior vieb: image

firefox browser: image

additional information I tried

set resourcesallowed+=<useCurrentUrl>~script
set resourcesallowed+=<useCurrentUrl>

two of this and also refreshed

Specs

I tried my best to look at all of the documentation in help and others. If the solution exists I apologize.

Jelmerro commented 8 months ago

This is a very weird bug, I am able to reproduce it so that's at least positive, but I have yet to find the cause for this. A plain Electron project does not have this issue, so there must be some kind of config or code interfering with setting the listener. As such, I tried to run the project without any preloads, meaning that there is no custom Vieb code running in the page, yet I still had this issue. So that indicates to me that this must be something to do with a setting of sorts. I'll let you know when i know more.

Jelmerro commented 8 months ago

It seems like it is similar to this issue: https://github.com/electron/electron/issues/31018, in that changing the contextIsolation value changes the behavior of this issue. If I enable contextIsolation it starts working again, regardless of other Vieb code being loaded or not, when disabled it even breaks this in a plain Electron test project (with webview enabled and sandbox disabled to allow requiring modules) even without a preload. This means that the problem lies with Electron. I'll see if I can bring this back to a smaller test case, as the Electron team refuses to look into this if there is a dependency on big projects such as Next.js or React. One of those projects must be using something that is implemented differently in Electron when contextIsolation is toggled, but I have yet to discover what that is.