Skip to content

Commit

Permalink
Bug/general fixes (#9)
Browse files Browse the repository at this point in the history
* 🔧 palette arrow navigation

* 🔧 fix browser module error
  • Loading branch information
gabriel-gn authored Mar 4, 2022
1 parent 0e256a2 commit 2f5cbe5
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 274 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Angular Version | NPM Version |
|-----------------|-------------|
| 13.2.3 | 13.0.2 |
| 13.2.3 | 13.0.3 |
| < 13.0.0 | 0.0.77 |

## Reference
Expand Down
532 changes: 274 additions & 258 deletions documentation.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mprisma/components",
"version": "13.0.2",
"version": "13.0.3",
"repository": {
"type": "git",
"url": "https://github.com/gabriel-gn/prisma-components.git"
Expand Down Expand Up @@ -37,11 +37,11 @@
"@storybook/components": "^6.4.19",
"@types/lodash": "^4.14.178",
"angular2-hotkeys": "^13.1.0",
"autoprefixer": "^10.3.7",
"bootstrap": "^5.1.3",
"lodash": "^4.17.21",
"ngx-cookie-service": "^13.1.2",
"popper.js": "^1.16.1",
"autoprefixer": "^10.3.7",
"postcss-flexbugs-fixes": "^5.0.2",
"react": "^16.14.0",
"react-dom": "^16.14.0",
Expand Down
18 changes: 12 additions & 6 deletions src/components/inputs/multi-select/multi-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ export class MultiSelectComponent implements OnInit, AfterViewInit {
*/
@Input() selectedOptions: MultiSelectOption[] = [];

public myControl: FormControl = new FormControl();
public readonly myControl: FormControl;
public inputValue: string = '';
public filteredOptions: Observable<MultiSelectOption[]>;

constructor(
private cdr: ChangeDetectorRef
) {
this.myControl = new FormControl();
}

ngOnInit(): void {
Expand All @@ -87,9 +88,13 @@ export class MultiSelectComponent implements OnInit, AfterViewInit {
this.clearInput();
}

displayFn(user: MultiSelectOption): string {
/**
* Função utilizada para colocar texto na caixa de input ao selecionar uma opção
* @param user
*/
displayFn(option: MultiSelectOption): string {
return '';
// return user && user.label ? user.label : '';
// return option && option.label ? option.label : '';
}

private _filter(label: string): MultiSelectOption[] {
Expand Down Expand Up @@ -124,9 +129,10 @@ export class MultiSelectComponent implements OnInit, AfterViewInit {
}

public openSelect(): void {
setTimeout(() => {
try { this.inputBoxEl.nativeElement.focus(); } catch (e) {}
}, 0);
// setTimeout(() => {
// try { this.inputBoxEl.nativeElement.focus(); } catch (e) {}
// }, 0);
this.trigger.openPanel();
}

public clearSelected(): void {
Expand Down
3 changes: 0 additions & 3 deletions src/components/inputs/multi-select/multi-select.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatAutocompleteModule} from '@angular/material/autocomplete';
import {MatInputModule} from '@angular/material/input';
import {CommonModule} from '@angular/common';
import {BrowserModule} from "@angular/platform-browser";


@NgModule({
declarations: [
Expand All @@ -17,7 +15,6 @@ import {BrowserModule} from "@angular/platform-browser";
],
imports: [
CommonModule,
BrowserModule,
FormsModule,
ReactiveFormsModule,
MatAutocompleteModule,
Expand Down
1 change: 1 addition & 0 deletions src/services/command-palette/dialog/dialog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
(keydown.arrowLeft)="$event.preventDefault(); goBackOneLevel()"
(keydown.arrowRight)="$event.preventDefault(); paletteEntryAction(childEntry)"
(keydown.enter)="$event.preventDefault(); paletteEntryAction(childEntry)"
(keydown.backspace)="$event.preventDefault(); focusSearchInput()"
class="palette-result-entry"
>
<p>{{childEntry.label}}{{hasChildEntries(childEntry) ? '...' : ''}}</p>
Expand Down
6 changes: 3 additions & 3 deletions src/services/command-palette/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class DialogComponent implements AfterViewInit, OnDestroy {
this.componentInjectorService.removeComponentFromBody(this.itself);
}

private focusSearchInput(): void {
public focusSearchInput(): void {
setTimeout(() => {
this.currentFocusedElement = this.rootPanelComponent;
this.rootPanelComponent.nativeElement.children[0].children[1].focus();
Expand All @@ -89,7 +89,7 @@ export class DialogComponent implements AfterViewInit, OnDestroy {
if (focusNextIndex >= arrayResultEntryElements.length) {
this.focusSearchInput();
}
else if (isNaN(focusNextIndex)) {
else if (!isNaN(focusNextIndex)) {
this.currentFocusedElement = arrayResultEntryElements[focusNextIndex];
this.currentFocusedElement.nativeElement.focus();
} else {
Expand All @@ -104,7 +104,7 @@ export class DialogComponent implements AfterViewInit, OnDestroy {
if (focusPreviousIndex < 0) {
this.focusSearchInput();
}
else if (isNaN(focusPreviousIndex)) {
else if (!isNaN(focusPreviousIndex)) {
this.currentFocusedElement = arrayResultEntryElements[focusPreviousIndex];
this.currentFocusedElement.nativeElement.focus();
} else {
Expand Down

1 comment on commit 2f5cbe5

@vercel
Copy link

@vercel vercel bot commented on 2f5cbe5 Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.