-
Notifications
You must be signed in to change notification settings - Fork 162
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(grid): expose editorOptions for the default editors and improve built-in editing for date/time cols (input formats) #14465
base: master
Are you sure you want to change the base?
Conversation
e8ca056
to
4c0b4fa
Compare
8268f79
to
b06fe16
Compare
if (value) { | ||
this._inputFormat = value; | ||
} |
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.
Hm, I think the check can be omitted - if the option can be falsy (and is by default) and used to behave that way too, it should be able to accept such value to revert to an initial state. Same goes for displayFormat
projects/igniteui-angular/src/lib/date-common/util/date-time.util.ts
Outdated
Show resolved
Hide resolved
projects/igniteui-angular/src/lib/date-common/util/date-time.util.ts
Outdated
Show resolved
Hide resolved
projects/igniteui-angular/src/lib/date-common/util/date-time.util.spec.ts
Outdated
Show resolved
Hide resolved
projects/igniteui-angular/src/lib/date-common/util/date-time.util.spec.ts
Outdated
Show resolved
Hide resolved
projects/igniteui-angular/src/lib/date-common/util/date-time.util.ts
Outdated
Show resolved
Hide resolved
if (value) { | ||
this._inputFormat = value; | ||
if (this.hasProjectedInputs) { | ||
this.updateInputFormat(); | ||
} | ||
} |
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.
Same logic with the picker base - the old functionality around updateInputFormat
didn't care if there was a value or not.
Also you could use super.inputFormat
to avoid rewriting the same get/set logic, IIRC it should work with our compile options. It's already in the state directive.
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.
Same could go for the displayFormat
, assuming the override is for documentation snippet purposes?
projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.ts
Outdated
Show resolved
Hide resolved
@@ -500,8 +512,9 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh | |||
/** @hidden */ | |||
protected override setPlaceholder(_value: string): void { } | |||
|
|||
private updateDefaultFormat(): void { | |||
this._defaultInputFormat = DateTimeUtil.getDefaultInputFormat(this.locale); | |||
private updateDefaultFormat(dataType: DataType = DataType.DateTime): void { |
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.
Um wouldn't this make the editor default to date-time format if not specified, where it used to default to date-only? Don't think that'd be expected and the param isn't used, so just leave it to the old default in getDefaultInputFormat
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.
Right, I changed this, but since this is related to the default format for the dateTime
column in the grid, thought before trying to come up with anything, it would be better to discuss how it should be addressed, after this change and according to the new implementation. Currently some tests will be failing.
So far, the input format was set to a default format property (ref) defined on the FieldType interface (ref). So it is hardcoded and also includes time parts.
So, if we'd like that to remain the same, I guess it should be additionally handled for the dateTime
column?
To give some more context, the input format will not be inferred from the displayFormat in this case, as the default display format for dateTime
col (medium
) contains non-numeric parts (ref here and here). So, it will resolve to the default one for the dateTimeEditorDirective, which will be date-only.
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.
Okay, was going to ask how the columns even manage the difference between date/date-time because either default on the editor won't work for both. That medium
format is unfortunate, but I guess it's the only reasonable option w/ time included :/
Regardless, changing the behavior of another component to suit the grid usage probably not the way to go. Would've also been nice if the spec actually specified the default inputFormat behavior rather than a remark on the API doc. Which reminds me multiple specs are also likely due an update once we're done moving around changes.
CHANGELOG.md
Outdated
@@ -28,6 +28,20 @@ For Firefox users, we provide limited scrollbar styling options through the foll | |||
- `--sb-thumb-bg-color`: Sets the background color of the scrollbar thumb. | |||
- `--sb-track-bg-color`: Sets the background color of the scrollbar track. | |||
|
|||
#### Column editor options | |||
- `ColumnType`, `IgxColumn` |
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.
@ddaribo I'd still describe the auto localized input format and infer from the display(pipe) format as a separate (first) point. That could even be more impactful for more people than the new option which is an override if the new functionality doesn't produce quite what you'd like :)
projects/igniteui-angular/src/lib/grids/columns/column.component.ts
Outdated
Show resolved
Hide resolved
let input = firstCell.nativeElement.querySelector('.igx-input-group__input'); | ||
expect((input as any).value).toEqual('01-10-2015 11:37 AM'); |
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.
Since you started cleaning up the hardcoded selector elsewhere, might as well continue to query By.directive(IgxDateTimeEditorDirective)
in all tests. Or make the selector a constant.
Also judging by the other tests at this point the editor isn't focused yet, right? So checking the the value will give you the display instead of checking the input format. IIRC, I think you need to wait for a rAF for the focus directive to kick in (i.e. tick(16)
), though you could as well just check the intputFormat
prop on the editor to confirm the column passed the correct options and the rest in theory is already covered by the editor tests.
Related to #14009 and #14010
Additional information (check all that apply):
Checklist:
feature/README.MD
updates for the feature docsREADME.MD
CHANGELOG.MD
updates for newly added functionalityng update
migrations for the breaking changes (migrations guidelines)TODO: refactor the column datat types spec after comments, update editors spec