From 8416359e7447cf9b596bf8f42520cc2bed8c0849 Mon Sep 17 00:00:00 2001 From: didimmova Date: Thu, 20 Nov 2025 14:46:32 +0200 Subject: [PATCH] fix(date-range): align 'to' label for daterange picker --- .../_date-range-picker-theme.scss | 17 ++++++++++++ .../date-range-picker.component.ts | 27 +++++++++++++++---- src/app/date-range/date-range.sample.html | 4 ++- src/app/date-range/date-range.sample.ts | 6 +++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/projects/igniteui-angular/core/src/core/styles/components/date-range-picker/_date-range-picker-theme.scss b/projects/igniteui-angular/core/src/core/styles/components/date-range-picker/_date-range-picker-theme.scss index fd2220f6547..c1cc48bb7b6 100644 --- a/projects/igniteui-angular/core/src/core/styles/components/date-range-picker/_date-range-picker-theme.scss +++ b/projects/igniteui-angular/core/src/core/styles/components/date-range-picker/_date-range-picker-theme.scss @@ -6,8 +6,12 @@ /// @param {Map} $theme - The theme used to style the component. @mixin date-range-picker($theme) { @include css-vars($theme); + $variant: map.get($theme, '_meta', 'theme'); %igx-date-range-picker { + @include sizable(); + --input-group-size: #{map.get($theme, 'size')}; + --component-size: var(--ig-size, #{var-get($theme, 'default-size')}); display: flex; > igx-icon { @@ -32,6 +36,8 @@ igx-date-range-end, %igx-date-range-picker__start, %igx-date-range-picker__end { + --size: var(--input-group-size) !important; + flex: 1 0 0%; } @@ -40,6 +46,17 @@ align-items: center; color: var-get($theme, 'label-color'); margin: 0 rem(8px); + height: var(--input-group-size); + + @if $variant != 'material' { + align-self: flex-end; + + &.input-has-hint { + align-self: center; + } + } @else { + align-self: flex-start; + } } %igx-date-range-picker-buttons { diff --git a/projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.ts b/projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.ts index c41644e1b8f..4b2789c892f 100644 --- a/projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.ts +++ b/projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.ts @@ -43,12 +43,24 @@ import { IgxCalendarContainerComponent } from '../date-picker/calendar-container import { PickerBaseDirective } from '../date-picker/picker-base.directive'; import { IgxOverlayOutletDirective } from 'igniteui-angular/directives'; import { - IgxInputDirective, IgxInputGroupComponent, IgxInputGroupType, IgxInputState, - IgxLabelDirective, IGX_INPUT_GROUP_TYPE, IgxSuffixDirective, + IgxInputDirective, + IgxInputGroupComponent, + IgxInputGroupType, + IgxInputState, + IgxLabelDirective, + IGX_INPUT_GROUP_TYPE, + IgxSuffixDirective, IgxPrefixDirective, - IgxReadOnlyInputDirective + IgxReadOnlyInputDirective, + IgxHintDirective } from 'igniteui-angular/input-group'; -import { IgxDateRangeEndComponent, IgxDateRangeInputsBaseComponent, IgxDateRangeSeparatorDirective, IgxDateRangeStartComponent, DateRangePickerFormatPipe } from './date-range-picker-inputs.common'; +import { + IgxDateRangeEndComponent, + IgxDateRangeInputsBaseComponent, + IgxDateRangeSeparatorDirective, + IgxDateRangeStartComponent, + DateRangePickerFormatPipe, +} from './date-range-picker-inputs.common'; import { IgxIconComponent } from 'igniteui-angular/icon'; import { fadeIn, fadeOut } from 'igniteui-angular/animations'; @@ -420,6 +432,9 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective @ContentChild(IgxLabelDirective) public label: IgxLabelDirective; + @ContentChild(IgxHintDirective) + public hint: IgxHintDirective; + @ContentChild(IgxPickerActionsDirective) public pickerActions: IgxPickerActionsDirective; @@ -550,7 +565,9 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective /** @hidden @internal */ public get separatorClass(): string { - return 'igx-date-range-picker__label'; + const classes = ['igx-date-range-picker__label']; + if (this.hint) classes.push('input-has-hint'); + return classes.join(' '); } protected override get toggleContainer(): HTMLElement | undefined { diff --git a/src/app/date-range/date-range.sample.html b/src/app/date-range/date-range.sample.html index 5fc2e1103e2..123c51f4357 100644 --- a/src/app/date-range/date-range.sample.html +++ b/src/app/date-range/date-range.sample.html @@ -46,7 +46,9 @@
Angular Date Range Picker, two inputs, template-driven form
type="text" [placeholder]="properties.placeholder" /> - Helper text + @if (properties.hint) { + {{ properties.hint }} + } diff --git a/src/app/date-range/date-range.sample.ts b/src/app/date-range/date-range.sample.ts index 05a64ef6460..bf7223905b5 100644 --- a/src/app/date-range/date-range.sample.ts +++ b/src/app/date-range/date-range.sample.ts @@ -148,6 +148,12 @@ export class DateRangeSampleComponent { defaultValue: 'MM/dd/yyyy' } }, + hint: { + label: 'Hint Text', + control: { + type: 'text' + } + }, displayFormat: { label: 'Display Format', control: {