diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b60050205..71cdd65667f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,7 +83,7 @@ ## [16.5.0](https://github.com/primefaces/primeng/tree/16.5.0) (2023-10-11) -[Full Changelog](https://github.com/primefaces/primeng/compare/16.4.1...16.5.0) +[Full Changelog](https://github.com/primefaces/primeng/compare/16.4.2...16.5.0) **Deprecated:** - SlideMenu: Deprecate from PrimeNG [\#13830](https://github.com/primefaces/primeng/issues/13830) @@ -111,6 +111,15 @@ - p-dialog: ExpressionChangedAfterItHasBeenCheckedError with attr.aria-labelledby [\#13636](https://github.com/primefaces/primeng/issues/13636) - Textarea: autoResize doesn't work when used inside a Dialog [\#9231](https://github.com/primefaces/primeng/issues/9231) +## [16.4.2](https://github.com/primefaces/primeng/tree/16.4.2) (2023-11-10) + +[Full Changelog](https://github.com/primefaces/primeng/compare/16.4.1...16.4.2) + +**Fixed bugs:** + +- TreeTable | Global filter to search tree-table is not returning all the relevant results [\#14082](https://github.com/primefaces/primeng/issues/14082) +- Dropdown | FocusTrap doesn't allow user to tab on next element [\#14083](https://github.com/primefaces/primeng/issues/14083) + ## [16.4.1](https://github.com/primefaces/primeng/tree/16.4.1) (2023-09-27) [Full Changelog](https://github.com/primefaces/primeng/compare/16.4.0...16.4.1) diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index 07cfcf70bae..d981d4cb3e4 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -1023,7 +1023,7 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return; } - if (!this.overlayViewChild || !this.overlayViewChild.overlayViewChild.nativeElement.contains(event.target)) { + if (!this.overlayViewChild || !this.overlayViewChild.overlayViewChild?.nativeElement.contains(event.target)) { DomHandler.focus(this.inputEL.nativeElement); } } @@ -1240,6 +1240,7 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr this.changeFocusedOptionIndex(event, optionIndex); event.preventDefault(); + event.stopPropagation(); } onArrowUpKey(event) { @@ -1260,6 +1261,7 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr this.changeFocusedOptionIndex(event, optionIndex); event.preventDefault(); + event.stopPropagation(); } } diff --git a/src/app/components/chips/chips.ts b/src/app/components/chips/chips.ts index 918ef706cd2..617267f1f2f 100755 --- a/src/app/components/chips/chips.ts +++ b/src/app/components/chips/chips.ts @@ -84,7 +84,7 @@ export const CHIPS_VALUE_ACCESSOR: any = { (paste)="onPaste($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" - [disabled]="disabled || maxedOut" + [disabled]="disabled || isMaxedOut" [ngStyle]="inputStyle" [class]="inputStyleClass" /> @@ -101,7 +101,7 @@ export const CHIPS_VALUE_ACCESSOR: any = { host: { class: 'p-element p-inputwrapper', '[class.p-inputwrapper-filled]': 'filled', - '[class.p-inputwrapper-focus]': 'focus', + '[class.p-inputwrapper-focus]': 'focused', '[class.p-chips-clearable]': 'showClear' }, providers: [CHIPS_VALUE_ACCESSOR], @@ -263,7 +263,7 @@ export class Chips implements AfterContentInit, ControlValueAccessor { return this.focusedIndex !== null ? `${this.id}_chips_item_${this.focusedIndex}` : null; } - private get isValueMaxLimited(): boolean { + get isMaxedOut(): boolean { return this.max && this.value && this.max === this.value.length; } @@ -459,7 +459,7 @@ export class Chips implements AfterContentInit, ControlValueAccessor { this.value = this.value || []; if (item && item.trim().length) { - if ((this.allowDuplicate || this.value.indexOf(item) === -1) && !this.isValueMaxLimited) { + if ((this.allowDuplicate || this.value.indexOf(item) === -1) && !this.isMaxedOut) { this.value = [...this.value, item]; this.onModelChange(this.value); this.onAdd.emit({ @@ -500,7 +500,7 @@ export class Chips implements AfterContentInit, ControlValueAccessor { break; case 'Enter': - if (inputValue && inputValue.trim().length && !this.maxedOut()) { + if (inputValue && inputValue.trim().length && !this.isMaxedOut) { this.addItem(event, inputValue, true); } @@ -530,7 +530,7 @@ export class Chips implements AfterContentInit, ControlValueAccessor { updateMaxedOut(): void { if (this.inputViewChild && this.inputViewChild.nativeElement) { - if (this.isValueMaxLimited) { + if (this.isMaxedOut) { // Calling `blur` is necessary because firefox does not call `onfocus` events // for disabled inputs, unlike chromium browsers. this.inputViewChild.nativeElement.blur(); @@ -544,10 +544,6 @@ export class Chips implements AfterContentInit, ControlValueAccessor { } } } - - maxedOut(): boolean { - return this.max && this.value && this.max === this.value.length; - } } @NgModule({ diff --git a/src/app/components/dropdown/dropdown.ts b/src/app/components/dropdown/dropdown.ts index 68256af5f32..58bb862fa4b 100755 --- a/src/app/components/dropdown/dropdown.ts +++ b/src/app/components/dropdown/dropdown.ts @@ -146,7 +146,7 @@ export class DropdownItem { (blur)="onInputBlur($event)" (keydown)="onKeyDown($event)" > - {{ label() === 'p-emptylabel' ? ' ' : label() || 'empty' }} + {{ label() === 'p-emptylabel' ? ' ' : label() }} {{ label() === 'p-emptylabel' ? ' ' : placeholder }} @@ -916,9 +916,9 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV }); label = computed(() => { - let selectedOptionIndex; - this.autoDisplayFirst ? (!this.modelValue() ? (selectedOptionIndex = -1) : (selectedOptionIndex = this.findFirstOptionIndex())) : (selectedOptionIndex = this.findSelectedOptionIndex()); - return this.modelValue() ? this.getOptionLabel(this.modelValue()) : selectedOptionIndex !== -1 ? this.getOptionLabel(this.visibleOptions()[selectedOptionIndex]) : this.placeholder || 'p-emptylabel'; + const selectedOptionIndex = this.findSelectedOptionIndex(); + + return selectedOptionIndex !== -1 ? this.getOptionLabel(this.visibleOptions()[selectedOptionIndex]) : this.placeholder || 'p-emptylabel'; }); constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig) { @@ -1051,6 +1051,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV this.updateModel(value, event); this.focusedOptionIndex.set(this.findSelectedOptionIndex()); isHide && this.hide(true); + this.onChange.emit({originalEvent: event, value: value}) } onOptionMouseEnter(event, index) { @@ -1062,16 +1063,21 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV updateModel(value, event?) { this.value = value; this.onModelChange(value); - if (this.value !== this.modelValue()) { - this.onChange.emit({ - originalEvent: event, - value: value - }); - } this.modelValue.set(value); this.selectedOptionUpdated = true; } + writeValue(value: any): void { + if (this.filter) { + this.resetFilter(); + } + this.value = value; + this.onModelChange(value); + this.modelValue.set(this.value) + this.updateEditableLabel(); + this.cd.markForCheck(); + } + isSelected(option) { return this.isValidOption(option) && ObjectUtils.equals(this.modelValue(), this.getOptionValue(option), this.equalityKey()); } @@ -1093,7 +1099,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV } getOptionLabel(option: any) { - return this.optionLabel ? ObjectUtils.resolveFieldData(option, this.optionLabel) : option && option.label !== undefined ? option.label : option; + return this.optionLabel ? ObjectUtils.resolveFieldData(option, this.optionLabel) : option && option?.label !== undefined ? option.label : option; } getOptionValue(option: any) { @@ -1127,16 +1133,6 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV return this.visibleOptions().filter((option) => !this.isOptionGroup(option)).length; } - writeValue(value: any): void { - if (this.filter) { - this.resetFilter(); - } - this.value = value; - this.updateModel(this.value); - this.updateEditableLabel(); - this.cd.markForCheck(); - } - /** * Callback to invoke on filter reset. * @group Method @@ -1190,6 +1186,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV this.onModelChange(value); this.updateModel(value, event); + this.onChange.emit({originalEvent: event, value: value}) } /** * Displays the panel. @@ -1221,7 +1218,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV let selectedListItem = DomHandler.findSingle(this.itemsWrapper, '.p-dropdown-item.p-highlight'); if (selectedListItem) { - selectedListItem.scrollIntoView({ block: 'nearest', inline: 'center' }); + selectedListItem.scrollIntoView({ block: 'nearest', inline: 'nearest' }); } } } @@ -1616,7 +1613,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV } onFirstHiddenFocus(event) { - const focusableEl = event.relatedTarget === this.focusInputViewChild.nativeElement ? DomHandler.getFirstFocusableElement(this.overlayViewChild.el.nativeElement, ':not(.p-hidden-focusable)') : this.focusInputViewChild.nativeElement; + const focusableEl = event.relatedTarget === this.focusInputViewChild?.nativeElement ? DomHandler.getFirstFocusableElement(this.overlayViewChild.el.nativeElement, ':not(.p-hidden-focusable)') : this.focusInputViewChild.nativeElement; DomHandler.focus(focusableEl); } @@ -1716,6 +1713,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV clear(event: Event) { this.updateModel(null, event); this.updateEditableLabel(); + this.onChange.emit({originalEvent: event, value: this.value}) this.onClear.emit(event); } } diff --git a/src/app/components/megamenu/megamenu.ts b/src/app/components/megamenu/megamenu.ts index 0978589245e..061a28c31c6 100755 --- a/src/app/components/megamenu/megamenu.ts +++ b/src/app/components/megamenu/megamenu.ts @@ -621,9 +621,7 @@ export class MegaMenu implements AfterContentInit, OnDestroy, OnInit { onItemMouseEnter(event: any) { if (!DomHandler.isTouchDevice()) { - if (this.dirty) { - this.onItemChange(event); - } + this.onItemChange(event); } } diff --git a/src/app/components/menubar/menubar.ts b/src/app/components/menubar/menubar.ts index 970b422902c..de2caaaecb6 100755 --- a/src/app/components/menubar/menubar.ts +++ b/src/app/components/menubar/menubar.ts @@ -662,7 +662,7 @@ export class Menubar implements AfterContentInit, OnDestroy, OnInit { onItemMouseEnter(event: any) { if (!DomHandler.isTouchDevice()) { - if (!this.mobileActive && this.dirty) { + if (!this.mobileActive) { this.onItemChange(event); } } diff --git a/src/app/components/multiselect/multiselect.ts b/src/app/components/multiselect/multiselect.ts index a5f7c8db426..b53c9bbc00e 100755 --- a/src/app/components/multiselect/multiselect.ts +++ b/src/app/components/multiselect/multiselect.ts @@ -317,13 +317,13 @@ export class MultiSelectItem {