Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit e1a5146

Browse files
crisbetokara
authored andcommitted
fix(datepicker): remove negative margin if triangle icon is disabled (#9853)
Fixes #9850.
1 parent 1d77c92 commit e1a5146

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/components/datepicker/datePicker.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ md-datepicker {
1212
// Don't let linebreaks happen between the open icon-button and the input.
1313
white-space: nowrap;
1414
overflow: hidden;
15-
16-
// Leave room for the down-triangle button to "overflow" it's parent without modifying scrollLeft.
17-
// This prevents the element from shifting right when opening via the triangle button.
18-
@include rtl-prop(padding-right, padding-left, $md-datepicker-triangle-button-width / 2, 0);
19-
@include rtl-prop(margin-right, margin-left, -$md-datepicker-triangle-button-width / 2, auto);
20-
2115
vertical-align: middle;
2216
}
2317

@@ -95,6 +89,12 @@ md-datepicker {
9589
}
9690
}
9791

92+
._md-datepicker-has-triangle-icon {
93+
// Leave room for the down-triangle button to "overflow" it's parent without modifying scrollLeft.
94+
// This prevents the element from shifting right when opening via the triangle button.
95+
@include rtl-prop(padding-right, padding-left, $md-datepicker-triangle-button-width / 2, 0);
96+
@include rtl-prop(margin-right, margin-left, -$md-datepicker-triangle-button-width / 2, auto);
97+
}
9898

9999
// Container for the datepicker input.
100100
.md-datepicker-input-container {

src/components/datepicker/js/datepickerDirective.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,20 @@
7878
'md-svg-src="' + $$mdSvgRegistry.mdCalendar + '"></md-icon>' +
7979
'</md-button>';
8080

81-
var triangleButton = (hiddenIcons === 'all' || hiddenIcons === 'triangle') ? '' :
82-
'<md-button type="button" md-no-ink ' +
81+
var triangleButton = '';
82+
83+
if (hiddenIcons !== 'all' && hiddenIcons !== 'triangle') {
84+
triangleButton = '' +
85+
'<md-button type="button" md-no-ink ' +
8386
'class="md-datepicker-triangle-button md-icon-button" ' +
8487
'ng-click="ctrl.openCalendarPane($event)" ' +
8588
'aria-label="{{::ctrl.locale.msgOpenCalendar}}">' +
8689
'<div class="md-datepicker-expand-triangle"></div>' +
8790
'</md-button>';
8891

92+
tElement.addClass(HAS_TRIANGLE_ICON_CLASS);
93+
}
94+
8995
return calendarButton +
9096
'<div class="md-datepicker-input-container" ng-class="{\'md-datepicker-focused\': ctrl.isFocused}">' +
9197
'<input ' +
@@ -155,7 +161,7 @@
155161
mdInputContainer.input = element;
156162
mdInputContainer.element
157163
.addClass(INPUT_CONTAINER_CLASS)
158-
.toggleClass(HAS_ICON_CLASS, attr.mdHideIcons !== 'calendar' && attr.mdHideIcons !== 'all');
164+
.toggleClass(HAS_CALENDAR_ICON_CLASS, attr.mdHideIcons !== 'calendar' && attr.mdHideIcons !== 'all');
159165

160166
if (!mdInputContainer.label) {
161167
$mdAria.expect(element, 'aria-label', attr.mdPlaceholder);
@@ -196,7 +202,10 @@
196202
var INPUT_CONTAINER_CLASS = '_md-datepicker-floating-label';
197203

198204
/** Class to be applied when the calendar icon is enabled. */
199-
var HAS_ICON_CLASS = '_md-datepicker-has-calendar-icon';
205+
var HAS_CALENDAR_ICON_CLASS = '_md-datepicker-has-calendar-icon';
206+
207+
/** Class to be applied when the triangle icon is enabled. */
208+
var HAS_TRIANGLE_ICON_CLASS = '_md-datepicker-has-triangle-icon';
200209

201210
/** Default time in ms to debounce input event by. */
202211
var DEFAULT_DEBOUNCE_INTERVAL = 500;

0 commit comments

Comments
 (0)