Skip to content

Hide autocomplete options panel on disabled or add hidePanel method. #9687

@Domvel

Description

@Domvel

Bug, feature request, or proposal:

(More a suggestion as a bug. But a unwanted behavior of users.)
Hide the options panel of autocomplete if the input element goes disabled.
Or add a method to hide the panel in an official way.

What is the expected behavior?

Hide the option panel if the input is disabled.
Also if the panel was displayed before the input disabled.

What is the current behavior?

The option panel still displayed. The user can select an item.
Also if the input is disabled. But note: Only when the clear button stops propagation.
That's a correct behavior but not as the user expected.

What are the steps to reproduce?

  1. User selects an item from mat-autocomplete. (works as expected.)
  2. User clicks again on the input to view the option, (ok)
  3. The user clicks on the clear button on the right (matSuffix).
    The method on the clear button disables the input and sets event.stopPropagation() to prevent the underlayed input get focused.
    Result: The options panel still showing. The user can select an item. Also if the input is disabled.

What is the use-case or motivation for changing an existing behavior?

The clear button stops the propagation becuase the button is over the input element.
I do not want to select the input on clear-button clicked. But the stopPropagation()
enables this "bug" here descripted. (User can select a option also if input is disabled after clear)

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

5.0.1

Is there anything else we should know?

It's possible to hide the panel like

myAutoComplete.panel.nativeElement.hidden = true;

But this will still hide the panel after user clicked into the input again.
Until the user clicked outside of the input an the input again.

Solutions:

  • Always hide the panel if the input is disabled.
  • Add a method like showPanel for hidePanel. But do not simple hidden = true of the native element. Because of the issue explained above.

I've found no hidePanel() method. Only a showPanel() method. What's wrong with a hide method?

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions