Skip to content

Commit

Permalink
Handle PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
atmgrifter00 committed Mar 5, 2024
1 parent 5054609 commit 13b9f94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/nimble-components/src/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ declare global {
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
type BooleanOrVoid = boolean | void;

const isListOption = (el: Element): el is ListOption => {
const isNimbleListOption = (el: Element): el is ListOption => {
return el instanceof ListOption;
};

Expand Down Expand Up @@ -353,15 +353,15 @@ export class Select extends FormAssociatedSelect implements ErrorPattern {
break;
}
case 'selected': {
if (isListOption(sourceElement)) {
if (isNimbleListOption(sourceElement)) {
this.selectedIndex = this.options.indexOf(sourceElement);
}
this.setSelectedOptions();
this.updateDisplayValue();
break;
}
case 'hidden': {
if (isListOption(sourceElement)) {
if (isNimbleListOption(sourceElement)) {
sourceElement.visuallyHidden = sourceElement.hidden;
}
this.updateDisplayValue();
Expand Down Expand Up @@ -773,7 +773,7 @@ export class Select extends FormAssociatedSelect implements ErrorPattern {
*/
protected override setDefaultSelectedOption(): void {
const options: ListboxOption[] = this.options
?? Array.from(this.children).filter(o => isListOption(o));
?? Array.from(this.children).filter(o => isNimbleListOption(o));

const optionIsSelected = (option: ListboxOption): boolean => {
return option.hasAttribute('selected') || option.selected;
Expand Down Expand Up @@ -845,10 +845,11 @@ export class Select extends FormAssociatedSelect implements ErrorPattern {

if (filter) {
this.filteredOptions = this.options.filter(option => {
const normalizedFilter = diacriticInsensitiveStringNormalizer(filter);
return (
!option.hidden
&& diacriticInsensitiveStringNormalizer(option.text).includes(
diacriticInsensitiveStringNormalizer(filter)
normalizedFilter
)
);
});
Expand All @@ -859,7 +860,7 @@ export class Select extends FormAssociatedSelect implements ErrorPattern {
}

this.options.forEach(o => {
if (isListOption(o)) {
if (isNimbleListOption(o)) {
if (!this.filteredOptions.includes(o)) {
o.visuallyHidden = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export class SelectPageObject {
* Click the option with the text provided by the 'displayText' parameter.
* @param value The text of the option to be selected
*/
public async clickOptionWithDisplayText(displayText: string): Promise<void> {
public async clickOptionWithDisplayText(
displayText: string
): Promise<void> {
if (!this.selectElement.open) {
await this.clickSelect();
}
Expand Down

0 comments on commit 13b9f94

Please sign in to comment.