File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
packages/material-ui-lab/src Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,21 @@ describe('<Autocomplete />', () => {
5454 } ) ;
5555 } ) ;
5656
57+ describe ( 'prop: loading' , ( ) => {
58+ it ( 'should show a loading message when open' , ( ) => {
59+ render (
60+ < Autocomplete
61+ { ...defaultProps }
62+ freeSolo
63+ loading
64+ renderInput = { ( params ) => < TextField autoFocus { ...params } /> }
65+ /> ,
66+ ) ;
67+ fireEvent . keyDown ( document . activeElement , { key : 'ArrowDown' } ) ;
68+ expect ( document . querySelector ( `.${ classes . paper } ` ) . textContent ) . to . equal ( 'Loading…' ) ;
69+ } ) ;
70+ } ) ;
71+
5772 describe ( 'prop: autoHighlight' , ( ) => {
5873 it ( 'should set the focus on the first item' , ( ) => {
5974 const options = [ 'one' , 'two' ] ;
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ export default function useAutocomplete(props) {
242242 const inputValueIsSelectedValue =
243243 ! multiple && value != null && inputValue === getOptionLabel ( value ) ;
244244
245- let popupOpen = open ;
245+ const popupOpen = open ;
246246
247247 const filteredOptions = popupOpen
248248 ? filterOptions (
@@ -263,8 +263,6 @@ export default function useAutocomplete(props) {
263263 )
264264 : [ ] ;
265265
266- popupOpen = freeSolo && filteredOptions . length === 0 ? false : popupOpen ;
267-
268266 if ( process . env . NODE_ENV !== 'production' ) {
269267 if ( value !== null && ! freeSolo && options . length > 0 ) {
270268 const missingValue = ( multiple ? value : [ value ] ) . filter (
@@ -405,7 +403,7 @@ export default function useAutocomplete(props) {
405403 } ) ;
406404
407405 React . useEffect ( ( ) => {
408- if ( ! open ) {
406+ if ( ! popupOpen ) {
409407 return ;
410408 }
411409
@@ -451,7 +449,7 @@ export default function useAutocomplete(props) {
451449 // eslint-disable-next-line react-hooks/exhaustive-deps
452450 } , [
453451 value ,
454- open ,
452+ popupOpen ,
455453 filterSelectedOptions ,
456454 changeHighlightedIndex ,
457455 setHighlightedIndex ,
You can’t perform that action at this time.
0 commit comments