Skip to content

Commit 77beaa3

Browse files
fix(edit-content): date pickers use fixed width and stay open until click-outside (#36156) (#36365)
### Proposed Changes Fixes the Date, Date/Time and Time field pickers in the new Edit Contentlet (issue #36156): * **Width** — Removed the `w-full` class, `[inputStyleClass]="'w-full'"` binding and the `width: 100%` SCSS override. The picker now uses PrimeNG's default datepicker sizing (`display: inline-flex`, hugging the input + dropdown button) instead of stretching full width. No hard-coded magic number. * **Close behavior** — Set `[hideOnDateTimeSelect]="false"` so the panel stays open after a date is clicked and only closes on click-outside. This lets users complete the time portion on Date/Time and Time fields. Consistent across all three field types. The selected value is still applied on `(onSelect)`, so it is correctly persisted when the picker closes. * Added spec coverage for both behaviors across Date, Date/Time and Time. https://github.com/user-attachments/assets/1ac2a867-7686-4004-964d-2874797f3f97 ### Checklist - [x] Tests - [ ] Translations - [x] Security Implications Contemplated (none — frontend presentation/UX only) ### Additional Info Single-component change: all three field types are rendered by `dot-calendar-field`, so the fix applies to Date, Date/Time and Time automatically. No API/backend changes. Verification: - `pnpm nx test edit-content` → 1871 passed (includes 6 new cases) - `pnpm nx lint edit-content` → 0 errors ### Screenshots Original | Updated :-------------------------:|:-------------------------: _full-width picker, closes on date click_ | _fixed-width picker, stays open until click-outside_ Closes #36156 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f8de42d commit 77beaa3

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

core-web/libs/edit-content/src/lib/fields/dot-edit-content-calendar-field/components/calendar-field/calendar-field.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
@let fieldTypeConfig = $fieldTypeConfig();
44

55
<p-datepicker
6-
class="w-full"
7-
[inputStyleClass]="'w-full'"
86
[class.ng-invalid]="hasError"
97
[class.ng-dirty]="hasError"
108
[formControl]="internalFormControl"
119
[defaultDate]="$defaultDate()"
1210
[timeOnly]="fieldTypeConfig.timeOnly"
1311
[showTime]="fieldTypeConfig.showTime"
12+
[hideOnDateTimeSelect]="false"
1413
(onSelect)="onCalendarChange($event)"
1514
(onClearClick)="onCalendarChange(null)"
1615
(onClear)="onCalendarChange(null)"

core-web/libs/edit-content/src/lib/fields/dot-edit-content-calendar-field/components/calendar-field/calendar-field.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// the ring encloses both the input and the calendar icon button as one unit.
33

44
:host ::ng-deep p-datepicker {
5-
display: flex;
6-
width: 100%;
5+
// Use PrimeNG's default datepicker sizing
6+
display: inline-flex;
77
border-radius: var(--p-inputtext-border-radius);
88
transition:
99
border-color var(--p-inputtext-transition-duration),

core-web/libs/edit-content/src/lib/fields/dot-edit-content-calendar-field/dot-edit-content-calendar-field.component.spec.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,61 @@ describe('DotEditContentCalendarFieldComponent', () => {
442442
});
443443
});
444444

445+
describe('Picker presentation (issue #36156)', () => {
446+
const buildHost = (fieldType: FIELD_TYPES) => {
447+
const field = { ...DATE_FIELD_MOCK, fieldType };
448+
spectator = createHost(
449+
`<form [formGroup]="formGroup">
450+
<dot-edit-content-calendar-field [field]="field" [contentlet]="contentlet" [utcTimezone]="utcTimezone" [contentType]="contentType" />
451+
</form>`,
452+
{
453+
hostProps: {
454+
formGroup: new FormGroup({
455+
[field.variable]: new FormControl()
456+
}),
457+
field,
458+
utcTimezone: null,
459+
contentType: CONTENT_TYPE_WITHOUT_EXPIRE,
460+
contentlet: createFakeContentlet({
461+
[field.variable]: null
462+
})
463+
}
464+
}
465+
);
466+
spectator.detectChanges();
467+
};
468+
469+
const FIELD_TYPES_UNDER_TEST = [
470+
['Date', FIELD_TYPES.DATE],
471+
['Date/Time', FIELD_TYPES.DATE_AND_TIME],
472+
['Time', FIELD_TYPES.TIME]
473+
] as const;
474+
475+
it.each(FIELD_TYPES_UNDER_TEST)(
476+
'should keep the %s picker open on selection (closes only on click-outside)',
477+
(_label, fieldType) => {
478+
buildHost(fieldType);
479+
480+
const calendar = spectator.query(DatePicker);
481+
expect(calendar.hideOnDateTimeSelect).toBe(false);
482+
}
483+
);
484+
485+
it.each(FIELD_TYPES_UNDER_TEST)(
486+
'should render the %s picker at PrimeNG default width, not full width',
487+
(_label, fieldType) => {
488+
buildHost(fieldType);
489+
490+
// No full-width override is applied; PrimeNG default sizing is used.
491+
const calendar = spectator.query(DatePicker);
492+
expect(calendar.inputStyleClass).toBeFalsy();
493+
494+
const datepickerEl = spectator.query('p-datepicker');
495+
expect(datepickerEl?.classList.contains('w-full')).toBe(false);
496+
}
497+
);
498+
});
499+
445500
describe('Default value handling', () => {
446501
beforeEach(() => {
447502
// Mock utility functions

0 commit comments

Comments
 (0)