railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.89k stars 2.25k forks source link

Uncaught ReferenceError: Cannot access 'started' before initialization #3655

Closed nikos83 closed 10 months ago

nikos83 commented 11 months ago

Describe the bug Rails admin is not fully functional I have Uncaught ReferenceError: Cannot access 'started' before initialization if I would like to click on datetime field or add new model.

Reproduction steps Install newest version rails with pg add rails_admin gem create few model with datetime try to open popup with date

Expected behavior Js should be load correctly

Additional context

Add any other context about the problem here. package.json

{
  "name": "app",
  "private": "true",
  "dependencies": {
    "@hotwired/stimulus": "^3.2.2",
    "@hotwired/turbo-rails": "^7.3.0",
    "@popperjs/core": "^2.11.8",
    "autoprefixer": "^10.4.16",
    "bootstrap": "^5.3.2",
    "bootstrap-icons": "^1.11.1",
    "esbuild": "^0.19.5",
    "nodemon": "^3.0.1",
    "postcss": "^8.4.31",
    "postcss-cli": "^10.1.0",
    "sass": "^1.69.5"
  },
  "scripts": {
    "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets",
    "build:css:compile": "sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules",
    "build:css:prefix": "postcss ./app/assets/builds/application.css --use=autoprefixer --output=./app/assets/builds/application.css",
    "build:css": "yarn build:css:compile && yarn build:css:prefix",
    "watch:css": "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \"yarn build:css\""
  },
  "browserslist": [
    "defaults"
  ]
}
mshibuya commented 10 months ago

Could you provide the full stack trace from the browser console?

nikos83 commented 10 months ago

Uncaught ReferenceError: Cannot access 'started' before initialization at start (application-b83775f799953add4a156c1fe73a91066cc5693c825701de487a163877d044db.js:56666:3) at application-b83775f799953add4a156c1fe73a91066cc5693c825701de487a163877d044db.js:4661:1 start @ application-b83775f799953add4a156c1fe73a91066cc5693c825701de487a163877d044db.js:56666 (anonymous) @ application-b83775f799953add4a156c1fe73a91066cc5693c825701de487a163877d044db.js:4661

function start() {
  if (!started) {
    started = true;
    document.addEventListener("click", didClick, true);
    document.addEventListener("submit", didSubmitForm, true);
    document.addEventListener("ajax:before", didSubmitRemoteElement);
  }
}

window.Turbo = Turbo;

start();

https://youtu.be/TWB5vpIMD5U

mshibuya commented 10 months ago

OK how come you think that this is a bug in RailsAdmin? It's because you're not defining the variable started correctly, right?

nikos83 commented 10 months ago

I'm not sure what's wrong and where just started fresh project on rails 7.2.0.alpha application added few models and I got this on the Rails Admin panel. It maybe some kind of rails bug (alpha version) but noting else none of js has been changed...

mshibuya commented 10 months ago

I suggest you to ask help on StackOverflow, not here.