Skip to content

Fix error in dialog_controller.js by checking for event before calling preventDefault #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jmarsh24
Copy link

There is a bug when rendering a dialog in the open state. The connect method tries to call preventDefault() on an event that doesn't exist which causes an error.

Steps to reproduce...

Render the following in a view template and you will get the following error
TypeError: Cannot read properties of undefined (reading 'preventDefault')
CleanShot 2025-05-24 at 19 26 57@2x

render RubyUI::Dialog.new(open: true) do
  render RubyUI::DialogContent.new do
    div do
      "hello"
    end
  end
end

This allows the event to be undefined and be able to open without issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant