-
Notifications
You must be signed in to change notification settings - Fork 601
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
feat: [DRAFT] adds select component #3902
Conversation
I'd love to see some screenshots or animated gifs of this in action 😉 |
0f93cfb
to
9b7c356
Compare
@@ -18,14 +18,18 @@ import { Dialog } from '@microsoft/fast-foundation'; | |||
import { Direction } from '@microsoft/fast-web-utilities'; | |||
import { Divider } from '@microsoft/fast-foundation'; | |||
import { Flipper } from '@microsoft/fast-foundation'; | |||
import { Listbox } from '@microsoft/fast-foundation'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a seperate pr/spec for listbox if we're calling it the "FAST listbox" which implies it is a generic building block component.
// Don't scroll the page for arrow keys, and spacebar. | ||
e.preventDefault(); | ||
switch (e.keyCode) { | ||
case KeyCodes.arrowDown: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling navigation across the options should be handled by the "listbox" component IMO.
private typeAheadTimeoutHandler: number = -1; | ||
private typeAheadExpired: boolean = false; | ||
private static readonly TYPE_AHEAD_TIMEOUT_MS = 1000; | ||
public handleTypeAhead(typedKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have type ahead as part of the initial feature set? Seems like an extra. There should be an option to enable/disable it at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should look to include basic type ahead here - I don't think we need full combobox behavior.
I'm definitely in favor of this being configurable per @scomea's suggestion. I'd suggest including a property for the timeout itself so that's configurable as well. I know most browsers tend to use 500ms
for this from some Open UI research we just discussed over there.
} | ||
|
||
public keypressHandler = (e: KeyboardEvent): void => { | ||
console.log('button pressed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull the console.logs :)
console.log('button pressed'); | ||
switch (e.keyCode) { | ||
case keyCodeSpace: | ||
console.log('space pressed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull the console.logs :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we do in this case? Have we not yet set up our keyboarding behavior of the listbox?
|
||
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ | ||
public clickHandler = (e: MouseEvent): void => { | ||
console.log(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a TODO?
|
||
export const OptionTemplate = html<Option>` | ||
<template | ||
tabindex="0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options can be disabled - I'd expect us to have a tabindex of -1 in that case.
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ | ||
public clickHandler = (e: MouseEvent): void => { | ||
(this.checked) ? this.checked = false : this.checked = true; | ||
this.$emit("oui-option-selection-change"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll want this event to be different - is this a change event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generic or "selection-change"
|
||
export const SelectTemplate = html<Select>` | ||
<template | ||
@oui-option-selection-change="${(x, c) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@change - we should drop all the oui modifiers.
switch (e.keyCode) { | ||
case KeyCodes.space: | ||
this.open = !this.open; | ||
console.log("Call one") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console
break; | ||
case KeyCodes.enter: | ||
this.open = !this.open; | ||
console.log("Call two") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console
break; | ||
case KeyCodes.enter: | ||
this.value = this.options[this.activeOptionIndex].value; | ||
console.log("Fire Enter", this.activeOptionIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console
case KeyCodes.escape: | ||
this.options[this.activeOptionIndex].removeAttribute('current'); | ||
this.open = !this.open; | ||
console.log("Call three") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console
this.updateSelectValue(value); | ||
this.typeAheadValue = ''; | ||
this.open = !this.open; | ||
console.log("Call six") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console please
|
||
private applyButtonControllerCode(): void { | ||
if (this.button) { | ||
console.log("This hits", this.button) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console please
Converting to draft because this is a draft PR. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
stalebot pls |
@radium-v You picked up work on this, yes? Do you need further review of this PR or is it better to wait for your update? |
@EisenbergEffect I'll have more commits incoming on this soon, should I add it to this PR or create a new one? |
@radium-v I don't have any strong opinions, so feel free to do whatever works best for your flow. |
@EisenbergEffect @radium-v let's snap a new PR and start fresh. |
Closing, see #4074. |
Description
Adds select component. Work in progress
Motivation & context
Issue type checklist
Is this a breaking change?
Adding or modifying component(s) in
@microsoft/fast-components
checklistProcess & policy checklist