@@ -237,6 +237,54 @@ module('Integration | Component | <Combobox>', function (hooks) {
237237 assert . dom ( getComboboxInput ( ) ) . hasValue ( 'B' ) ;
238238 } ) ;
239239
240+ test ( 'selecting an option puts the display value into Combobox.Input when displayValue is provided and values are objects' , async function ( assert ) {
241+ this . set ( 'onChange' , ( value ) => {
242+ this . set ( 'value' , value ) ;
243+ } ) ;
244+
245+ this . setProperties ( {
246+ value : null ,
247+ a : { value : 'a' } ,
248+ b : { value : 'b' } ,
249+ c : { value : 'c' } ,
250+ displayValue : ( option ) => {
251+ return option ?. value ?. toUpperCase ( ) || 'None' ;
252+ } ,
253+ } ) ;
254+
255+ await render ( hbs `
256+ <Combobox
257+ @value={{this.value}}
258+ @onChange={{this.onChange}}
259+ as |combobox|
260+ >
261+ <combobox.Input @displayValue={{this.displayValue}}/>
262+ <combobox.Button data-test="headlessui-combobox-button-2">Trigger</combobox.Button>
263+ <combobox.Options as |options|>
264+ <options.Option @value={{this.a}}>Option A</options.Option>
265+ <options.Option @value={{this.b}}>Option B</options.Option>
266+ <options.Option @value={{this.c}}>Option C</options.Option>
267+ </combobox.Options>
268+ </Combobox>
269+ ` ) ;
270+
271+ await click ( getComboboxButton ( ) ) ;
272+ assertComboboxList ( { state : ComboboxState . Visible } ) ;
273+
274+ await click ( getComboboxOptions ( ) [ 1 ] ) ;
275+ assert . dom ( getComboboxInput ( ) ) . hasValue ( 'B' ) ;
276+
277+ await click ( getComboboxButton ( ) ) ;
278+ assertComboboxList ( { state : ComboboxState . Visible } ) ;
279+
280+ assert . dom ( getComboboxInput ( ) ) . hasValue ( 'B' ) ;
281+
282+ await click ( document . body ) ;
283+ assertComboboxList ( { state : ComboboxState . InvisibleUnmounted } ) ;
284+
285+ assert . dom ( getComboboxInput ( ) ) . hasValue ( 'B' ) ;
286+ } ) ;
287+
240288 test ( 'opening and closing the combobox should not trigger spurious onChange events on the input' , async function ( assert ) {
241289 let inputOnChangeCallCount = 0 ;
242290 let inputOnChangeValues = [ ] ;
0 commit comments