Skip to content

[Bug Fix] Prevent Command dialog stacking#386

Open
djalmaaraujo wants to merge 2 commits into
mainfrom
da/issue-230-command-single-dialog
Open

[Bug Fix] Prevent Command dialog stacking#386
djalmaaraujo wants to merge 2 commits into
mainfrom
da/issue-230-command-single-dialog

Conversation

@djalmaaraujo
Copy link
Copy Markdown
Contributor

Summary

  • Mark cloned Command dialog content so the controller can detect an already-open dialog
  • Refocus the existing dialog input instead of appending another modal on repeated keybindings
  • Update docs controller copy and add component markup coverage

Closes #230

Testing

  • docker run --rm -v ruby_ui_bundle:/usr/local/bundle -v /Users/djalmaaraujo/dev/linkana/ruby_ui-issue-230:/workspace -w /workspace/gem ruby:3.4.7 bash -lc 'bundle install && bundle exec rake test TEST=test/ruby_ui/command_test.rb'

@djalmaaraujo djalmaaraujo requested a review from cirdes as a code owner May 7, 2026 13:27
this.selectedIndex = -1;
}

focusDialogInput(dialog) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it re-implements Stimulus target lookup by hand and hard-codes the controller identifier inside a selector string. If the controller is ever renamed, the input target moves, or the input gets wrapped in another element, this silently stops working, and the controller is now coupled to another instance's internal markup.

Using querySelector is a code smell in hotwire

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.

Multiple modals stack up when using command component in demo

2 participants