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 2
2
3
3
module RubyUI
4
4
class Combobox < Base
5
- def initialize ( term : "items" , **)
5
+ def initialize ( term : nil , **)
6
6
@term = term
7
7
super ( **)
8
8
end
@@ -18,7 +18,8 @@ def default_attrs
18
18
role : "combobox" ,
19
19
data : {
20
20
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"
22
23
}
23
24
}
24
25
end
Original file line number Diff line number Diff line change @@ -53,12 +53,12 @@ export default class extends Controller {
53
53
updateTriggerContent ( ) {
54
54
const checkedInputs = this . inputTargets . filter ( input => input . checked )
55
55
56
- if ( checkedInputs . length == 0 ) {
56
+ if ( checkedInputs . length === 0 ) {
57
57
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 ) {
61
59
this . triggerContentTarget . innerText = `${ checkedInputs . length } ${ this . termValue } `
60
+ } else {
61
+ this . triggerContentTarget . innerText = checkedInputs . map ( ( input ) => this . inputContent ( input ) ) . join ( ", " )
62
62
}
63
63
}
64
64
You can’t perform that action at this time.
0 commit comments