File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 22
33module RubyUI
44 class Combobox < Base
5- def initialize ( term : "items" , **)
5+ def initialize ( term : nil , **)
66 @term = term
77 super ( **)
88 end
@@ -18,7 +18,8 @@ def default_attrs
1818 role : "combobox" ,
1919 data : {
2020 controller : "ruby-ui--combobox" ,
21- ruby_ui__combobox_term_value : @term . to_s
21+ ruby_ui__combobox_term_value : @term ,
22+ action : "turbo:morph@window->ruby-ui--combobox#updateTriggerContent"
2223 }
2324 }
2425 end
Original file line number Diff line number Diff line change @@ -53,12 +53,12 @@ export default class extends Controller {
5353 updateTriggerContent ( ) {
5454 const checkedInputs = this . inputTargets . filter ( input => input . checked )
5555
56- if ( checkedInputs . length == 0 ) {
56+ if ( checkedInputs . length === 0 ) {
5757 this . triggerContentTarget . innerText = this . triggerTarget . dataset . placeholder
58- } else if ( checkedInputs . length === 1 ) {
59- this . triggerContentTarget . innerText = this . inputContent ( checkedInputs [ 0 ] )
60- } else {
58+ } else if ( this . termValue && checkedInputs . length > 1 ) {
6159 this . triggerContentTarget . innerText = `${ checkedInputs . length } ${ this . termValue } `
60+ } else {
61+ this . triggerContentTarget . innerText = checkedInputs . map ( ( input ) => this . inputContent ( input ) ) . join ( ", " )
6262 }
6363 }
6464
You can’t perform that action at this time.
0 commit comments