-
Notifications
You must be signed in to change notification settings - Fork 223
#CX-20457: Date Time picker: fix localised date format and disable user typing #2010
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
base: main
Are you sure you want to change the base?
Changes from all commits
ea8a9de
cd4403a
4036c67
f2725a8
1c62a07
fd60534
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 |
|---|---|---|
|
|
@@ -66,10 +66,12 @@ export namespace DatePicker { | |
| @property({ type: String }) htmlId = ""; | ||
| @property({ type: String }) label = ""; | ||
| @property({ type: String }) ariaLabel: string | null = null; | ||
| @property({ type: String }) displayValue: string | null = null; | ||
| @property({ type: Boolean }) required = false; | ||
| @property({ type: String, reflect: true }) errorMessage = ""; | ||
| @property({ type: Boolean, attribute: "custom-trigger" }) customTrigger = false; | ||
| @property({ type: Boolean }) isMenuOverlayOpen = false; | ||
| @property({ type: Boolean }) allowUserTextInput = false; | ||
| @property({ type: Boolean }) newMomentum?: boolean = undefined; | ||
| @property({ type: Boolean, attribute: "compact-input" }) compactInput?: boolean = undefined; | ||
| @property({ type: Object, attribute: false }) controlButtons?: DatePickerControlButtons = undefined; | ||
|
|
@@ -350,7 +352,7 @@ export namespace DatePicker { | |
| class="cancel-button" | ||
| aria-label=${ifDefined(this.controlButtons.cancel?.ariaLabel)} | ||
| ?disabled=${this.controlButtons.cancel?.disabled ?? false} | ||
| @click=${this.onCancelClick} | ||
| @button-click=${this.onCancelClick} | ||
| variant="secondary" | ||
| > | ||
| ${this.controlButtons.cancel.value} | ||
|
|
@@ -363,7 +365,7 @@ export namespace DatePicker { | |
| class="apply-button" | ||
| aria-label=${ifDefined(this.controlButtons.apply?.ariaLabel)} | ||
| ?disabled=${this.controlButtons.apply?.disabled ?? false} | ||
| @click=${this.onApplyClick} | ||
| @button-click=${this.onApplyClick} | ||
| variant="primary" | ||
| > | ||
| ${this.controlButtons.apply.value} | ||
|
|
@@ -425,7 +427,8 @@ export namespace DatePicker { | |
| role="combobox" | ||
| ?newMomentum=${this.computedNewMomentum} | ||
| placeholder=${this.getPlaceHolderString()} | ||
| value=${ifDefined(this.value ?? undefined)} | ||
| value=${this.displayValue ?? ifDefined(this.value ?? undefined)} | ||
| .allowUserTextInput=${this.allowUserTextInput} | ||
|
Contributor
Author
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. chatting with James N and we agreed to disable user text input when using localised dates |
||
| htmlId=${this.htmlId} | ||
| label=${this.label} | ||
| ariaLabel=${this.getAriaLabel()} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,7 @@ export namespace Input { | |
| @property({ type: Boolean }) clear = false; | ||
| @property({ type: String }) clearAriaLabel = ""; | ||
| @property({ type: Boolean }) compact = false; | ||
| @property({ type: Boolean }) allowUserTextInput = true; | ||
| @property({ type: String }) containerSize: Input.ContainerSize = "small-12"; | ||
| @property({ type: Boolean }) disabled = false; | ||
| @property({ type: String }) id = ""; | ||
|
|
@@ -452,7 +453,7 @@ export namespace Input { | |
| id=${this.htmlId} | ||
| role=${this.role} | ||
| placeholder=${this.placeholder} | ||
| ?readonly=${this.readOnly || this.disabled} | ||
|
Contributor
Author
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. the reson i added this new allowUserTextInput prop instead of just using readOnly is that readOnly also affects styling! |
||
| ?readonly=${this.readOnly || this.disabled || !this.allowUserTextInput} | ||
| min=${ifDefined(this.min)} | ||
| max=${ifDefined(this.max)} | ||
| maxlength=${ifDefined(this.maxLength)} | ||
|
|
||
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.
using disaplyValue instead of value allows us to sidestep all the awkward issues with the pickers attempting to interpret their own value as DateTime objects (which won't work for localised dates!)