Skip to content

Commit

Permalink
fix(DatePicker): correct input alignment without label (#2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jun 19, 2024
1 parent f8b3dc3 commit 25fe56d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-taxis-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@razorpay/blade": patch
---

fix(DatePicker): correct input alignment without label
7 changes: 4 additions & 3 deletions packages/blade/src/components/DatePicker/DateInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ const _DatePickerInput = (
const isMobile = useIsMobile();
const format = 'DD/MM/YYYY';
const isLarge = size === 'large';
const hasLabel = typeof label === 'string' ? Boolean(label) : Boolean(label?.start || label?.end);
const isLabelPositionLeft = labelPosition === 'left';
const isLabelPositionTop = labelPosition === 'top';
const isLabelPositionVisuallyTop = isLabelPositionTop || isMobile;
const hasLabel = Boolean(label);
const isLabelPositionVisuallyTop = hasLabel && (isLabelPositionTop || isMobile);

const { locale } = useDatesContext();

if (selectionType == 'single') {
Expand Down Expand Up @@ -183,7 +184,7 @@ const _DatePickerInput = (
size="medium"
marginTop={
// Hacky layouting because the we cannot put this inside the internal layout of BaseInput.
(hasLabel && !isLabelPositionLeft) || isMobile
hasLabel && (!isLabelPositionLeft || isMobile)
? `calc(${makeSize(iconVerticalMargin[size])} + ${makeSize(
isLarge ? sizeTokens[20] : sizeTokens[15],
)})`
Expand Down

0 comments on commit 25fe56d

Please sign in to comment.