File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
elements/pfe-autocomplete Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 11## Prerelease 55 ( TBD )
22
3+ - [ ] ( https://github.com/patternfly/patternfly-elements/commit/ ) feat: pfe-autocomplete - fire custom event when dropdown is shown
34- [ ] ( https://github.com/patternfly/patternfly-elements/commit/ ) fix: pfelement - restore pfelement tests (#1018 )
45- [ fbe4423] ( https://github.com/patternfly/patternfly-elements/commit/fbe442396f06b0a097366512b698dc0b6d5e1f9f ) fix: improve CLS rating in lighthouse (#1020 )
56
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class PfeAutocomplete extends PFElement {
3131 return {
3232 search : `${ this . tag } :search-event` ,
3333 select : `${ this . tag } :option-selected` ,
34+ optionsShown : `${ this . tag } :options-shown` ,
3435 slotchange : `slotchange`
3536 } ;
3637 }
@@ -293,6 +294,9 @@ class PfeAutocomplete extends PFElement {
293294 this . activeIndex = null ;
294295 this . _dropdown . setAttribute ( "open" , true ) ;
295296 this . _dropdown . setAttribute ( "active-index" , null ) ;
297+ this . emitEvent ( PfeAutocomplete . events . optionsShown , {
298+ composed : true
299+ } ) ;
296300 }
297301
298302 _optionSelected ( e ) {
Original file line number Diff line number Diff line change 133133 } ) ;
134134 } ) ;
135135
136+ it ( 'should fire a pfe-autocomplete:options-shown event when the droplist is shown to the user' , done => {
137+ flush ( ( ) => {
138+ const items = [ 'option 1' , 'option 2' ] ;
139+
140+ autocompleteElem . autocompleteRequest = function ( params , callback ) {
141+ const regx = new RegExp ( "\^" + params . query , "i" ) ;
142+ callback ( items . filter ( function ( item ) {
143+ return regx . test ( item ) ;
144+ } ) ) ;
145+ } ;
146+
147+ autocompleteElem . addEventListener ( "pfe-autocomplete:options-shown" , function ( event ) {
148+ assert . equal ( droplistElem . getAttribute ( "open" ) , "true" ) ;
149+ done ( ) ;
150+ } ) ;
151+
152+ autocompleteElem . _sendAutocompleteRequest ( "o" ) ;
153+ } ) ;
154+ } ) ;
155+
136156 it ( 'should fire pfe-autocomplete:search-event after user click on an option' , done => {
137157 flush ( ( ) => {
138158 droplistElem . data = [ 'option 1' , 'option 2' ] ;
You can’t perform that action at this time.
0 commit comments