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

Dialog: add provideBrnDialogConfig to override input values #608

Open
1 of 2 tasks
marcjulian opened this issue Feb 19, 2025 · 1 comment · May be fixed by #610
Open
1 of 2 tasks

Dialog: add provideBrnDialogConfig to override input values #608

marcjulian opened this issue Feb 19, 2025 · 1 comment · May be fixed by #610
Labels
enhancement New feature or request

Comments

@marcjulian
Copy link
Contributor

marcjulian commented Feb 19, 2025

Which scope/s are relevant/related to the feature request?

dialog

Information

I am implementing an AutocompleteTriggerDirective and the inputs could be set in the constructor before #599.

@Directive({
  selector: '[psAutocompleteTrigger]',
  standalone: true,
  host: {
    '(click)': 'open()',
  },
})
export class AutocompleteTriggerDirective {
  private readonly _host = inject(ElementRef, { host: true });

  private _brnDialog = inject(BrnDialogComponent, { optional: true });

  public readonly disabled = input<boolean, BooleanInput>(false, {
    transform: booleanAttribute,
  });

  constructor() {
    if (!this._brnDialog) return;

    this._brnDialog.attachTo = this._host.nativeElement;
    // otherwise the input field will loose focus
    this._brnDialog.autoFocus = 'first-heading';
    this._brnDialog.closeOnOutsidePointerEvents = true;
  }

  open() {
    if (this.disabled()) return;

    this._brnDialog?.open();
  }
}

Some inputs have a mutable signal like attachTo and closeOnOutsidePointerEvents, but autoFocus is just an signal input. I can update the inputs to use the new mutable... signal states, but autoFocus is not included.

- this._brnDialog.attachTo = this._host.nativeElement;
+ this._brnDialog.mutableAttachTo().set(this._host.nativeElement);
- this._brnDialog.autoFocus = 'first-heading'; // no option to change the input
- this._brnDialog.closeOnOutsidePointerEvents = true;
+ this._brnDialog.mutableCloseOnOutsidePointerEvents().set(true);

A provideBrnDialogConfig would allow to update config values like closeOnOutsidePointerEvents, autoFocus and more programmatically.

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@marcjulian marcjulian added the enhancement New feature or request label Feb 19, 2025
@marcjulian
Copy link
Contributor Author

There is already https://github.com/spartan-ng/spartan/blob/main/libs/brain/dialog/src/lib/brn-dialog-token.ts so we can add more options to the config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant