-
Notifications
You must be signed in to change notification settings - Fork 76
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(pagination, split-button, dropdown, date-picker) action-group): add setFocus method #6405
Changes from all commits
1c92826
d300a3a
7fba526
861c73d
36d6463
00cea63
68f4086
d6898c2
a9e7a75
60d39ea
1d3f53d
3c62f5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { | |
EventEmitter, | ||
h, | ||
Host, | ||
Method, | ||
Prop, | ||
State, | ||
VNode, | ||
|
@@ -19,6 +20,12 @@ import { | |
HoverRange, | ||
setEndOfDay | ||
} from "../../utils/date"; | ||
import { | ||
componentLoaded, | ||
LoadableComponent, | ||
setComponentLoaded, | ||
setUpLoadableComponent | ||
} from "../../utils/loadable"; | ||
import { | ||
connectLocalized, | ||
disconnectLocalized, | ||
|
@@ -46,7 +53,7 @@ import { DateLocaleData, getLocaleData, getValueAsDateRange } from "./utils"; | |
delegatesFocus: true | ||
} | ||
}) | ||
export class DatePicker implements LocalizedComponent, T9nComponent { | ||
export class DatePicker implements LocalizedComponent, LoadableComponent, T9nComponent { | ||
//-------------------------------------------------------------------------- | ||
// | ||
// Element | ||
|
@@ -188,6 +195,19 @@ export class DatePicker implements LocalizedComponent, T9nComponent { | |
|
||
@State() endAsDate: Date; | ||
|
||
//-------------------------------------------------------------------------- | ||
// | ||
// Public Methods | ||
// | ||
//-------------------------------------------------------------------------- | ||
|
||
/** Sets focus on the component's first focusable element. */ | ||
@Method() | ||
async setFocus(): Promise<void> { | ||
await componentLoaded(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sidebar: maybe we need a new util or to update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that could be nice. Matt started a PR (#6156) to try to cut down the |
||
this.el.focus(); | ||
} | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Lifecycle | ||
|
@@ -218,12 +238,17 @@ export class DatePicker implements LocalizedComponent, T9nComponent { | |
} | ||
|
||
async componentWillLoad(): Promise<void> { | ||
setUpLoadableComponent(this); | ||
await this.loadLocaleData(); | ||
this.onMinChanged(this.min); | ||
this.onMaxChanged(this.max); | ||
await setUpMessages(this); | ||
} | ||
|
||
componentDidLoad(): void { | ||
setComponentLoaded(this); | ||
} | ||
|
||
render(): VNode { | ||
const date = dateFromRange( | ||
this.range && Array.isArray(this.valueAsDate) ? this.valueAsDate[0] : this.valueAsDate, | ||
|
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.
Nice cleanup. Could you also add a
await page.waitForChanges();
here?