Skip to content

Commit

Permalink
Select placeholder (#1842)
Browse files Browse the repository at this point in the history
# Pull Request

## 🤨 Rationale

- #350
  • Loading branch information
atmgrifter00 authored Mar 5, 2024
1 parent 5c4da61 commit 19643f4
Show file tree
Hide file tree
Showing 12 changed files with 479 additions and 173 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Adding placeholder behavior for Select",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
23 changes: 22 additions & 1 deletion packages/nimble-components/src/list-option/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
DesignSystem,
ListboxOption as FoundationListboxOption
} from '@microsoft/fast-foundation';
import { observable } from '@microsoft/fast-element';
import { observable, attr } from '@microsoft/fast-element';
import { styles } from './styles';
import { template } from './template';

Expand All @@ -19,6 +19,27 @@ export class ListOption extends FoundationListboxOption {
/** @internal */
public contentSlot!: HTMLSlotElement;

/**
* The hidden state of the element.
*
* @public
* @defaultValue - false
* @remarks
* HTML Attribute: hidden
*/
@attr({ mode: 'boolean' })
public override hidden = false;

/**
* @internal
* This attribute is required to allow use-cases that offer dynamic filtering
* (like the Select) to visually hide options that are filtered out, but still
* allow users to use the native 'hidden' attribute without it being affected
* by the filtering process.
*/
@attr({ attribute: 'visually-hidden', mode: 'boolean' })
public visuallyHidden = false;

/** @internal */
@observable
public hasOverflow = false;
Expand Down
26 changes: 15 additions & 11 deletions packages/nimble-components/src/list-option/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ export const styles = css`
height: ${controlHeight};
}
[part='start'] {
display: none;
}
.content {
padding: 8px 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
:host([aria-selected='true']) {
box-shadow: none;
outline: none;
Expand Down Expand Up @@ -69,6 +58,21 @@ export const styles = css`
cursor: default;
}
:host([visually-hidden]) {
display: none;
}
[part='start'] {
display: none;
}
.content {
padding: 8px 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.content[disabled] {
box-shadow: none;
outline: none;
Expand Down
Loading

0 comments on commit 19643f4

Please sign in to comment.