Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues if usage of [isOpen] with variable #816

Closed
stretau opened this issue Sep 18, 2018 · 5 comments
Closed

issues if usage of [isOpen] with variable #816

stretau opened this issue Sep 18, 2018 · 5 comments

Comments

@stretau
Copy link

stretau commented Sep 18, 2018

Describe the bug
If you use the [isOpen] functionality for ng-select with a variable its somehow not possible to get in Defaultmode (as it is if you NOT use [isOpen])

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/ng-select-u8ezpw?file=app/app.component.ts

Use see the implementation like

<ng-select [items]="cities"
                   appendTo="body"
                   bindLabel="name"
                   placeholder="Select city"
                   [multiple]="true"
                   [isOpen]="myOpenVar"
                   [(ngModel)]="selectedCity">
        </ng-select>

if the myOpenVar is true/false everything works as expected. with true the searchlayer is (always) open, if false the searchlayer never opens. But if you use the "default"-value "-" like its mentioned here (https://github.com/ng-select/ng-select#api) the behavior is like [isOpen]=true

Expected behavior
Consider a situation where you want fill all the options dynamically by a configuration. Maybe the normal/default implementation should be an ng-select behavior without the [isOpen] functionality. But e.g false or true should be an option.

If [isOpen] is not provided in the config, then myOpenVar should get a value that ng-select behaves like [isOpen] is not provided, that means "open layer onclick" and "close layer on select":

summary
So it should be possible to get all 3 states for ng-select (isOpen true, isOpen false, isOpen default) by providing via variable.

Desktop (please complete the following information):
newest Chrome
angular6 and ng-select 2.9.0

@varnastadeus
Copy link
Member

- means that there is no default value

@stretau
Copy link
Author

stretau commented Sep 19, 2018

- means that there is no default value

ok thx. So does this then mean, if I use [isOpen] than there is no way to get the behavior like its not used? Is this a bug? Is this a feature?

@varnastadeus
Copy link
Member

I think this could be improvement to act as usual if value is not true or false

AndersTornkvist added a commit to AndersTornkvist/ng-select that referenced this issue Dec 31, 2018
* remotes/main/master: (25 commits)
  chore(release): 2.13.3
  fix: keep selected items while bindValue is incorrect closes ng-select#993
  chore(release): 2.13.2
  fix: appended dropdown position (ng-select#957)
  chore(release): 2.13.1
  fix: map selected items while source changed closes ng-select#980, ng-select#977, ng-select#959
  chore(release): 2.13.0
  [fix] - $event.path does not work in Safari and Firefox. Replace with $event.composedPath(). (ng-select#968)
  feat(templates): add searchTerm to header and footer (ng-select#961)
  chore(release): 2.12.1
  chore: include scss with package closes ng-select#909
  fix: use classList instead of className closes ng-select#940
  add aria-selected attribute on selected items (ng-select#936)
  fix: handler mousedown for clear event when used animation library (ng-select#931)
  chore(release): 2.12.0
  feat(autofocus): focus if attribute is present (ng-select#924)
  feat(isOpen): treat undefined value as default behaviour closes ng-select#816
  feat: allow to customise clear icon fixes ng-select#835
  chore(demo): fix virtual scroll example closes ng-select#921
  fix: keep items order while mapping selected options fixes ng-select#907
  ...
NickMele pushed a commit to NickMele/ng-select that referenced this issue Apr 12, 2019
@raysuelzer
Copy link

raysuelzer commented Sep 4, 2020

The ngChanges which sets manually open seems to run after the dialog has already been closed by an outside click. The original intent of this feature was to make is so that an outside click would not close the select. For example, using a material overlay component inside the template of ng-select will cause the overlay to be rendered outside of the select and thus trigger the dialog to be closed.

I think that a solution might be to allow some elementRefs or selectors to be passed which will be ignored by the outside click directive.

Or, delay the call to close() until after changeDetection has run. Calling close() on outsideClick will happen before the props are updated.

@tesseris
Copy link

The ngChanges which sets manually open seems to run after the dialog has already been closed by an outside click. The original intent of this feature was to make is so that an outside click would not close the select. For example, using a material overlay component inside the template of ng-select will cause the overlay to be rendered outside of the select and thus trigger the dialog to be closed.

I think that a solution might be to allow some elementRefs or selectors to be passed which will be ignored by the outside click directive.

Or, delay the call to close() until after changeDetection has run. Calling close() on outsideClick will happen before the props are updated.

Current behavior is useless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants