Skip to content

Commit

Permalink
[MISC][WL] extend the hiding date range input action buttons to mobil…
Browse files Browse the repository at this point in the history
…e if withButton=false
  • Loading branch information
ngweili committed Sep 12, 2024
1 parent f7d9c7f commit f1c18e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
10 changes: 1 addition & 9 deletions src/date-range-input/date-range-input.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import dayjs from "dayjs";
import { useEffect, useRef, useState } from "react";
import { useMediaQuery } from "react-responsive";
import { MediaWidths } from "../media";
import {
DropdownRenderProps,
ElementWithDropdown,
Expand Down Expand Up @@ -63,7 +61,7 @@ export const DateRangeInput = ({
onFocus,
onBlur,
onYearMonthDisplayChange,
withButton: _withButton = true,
withButton = true,
variant = "range",
numberOfDays = 7,
readOnly,
Expand Down Expand Up @@ -188,17 +186,11 @@ export const DateRangeInput = ({
const calendarRef = useRef<InternalCalendarRef>();
const startInputRef = useRef<StandaloneDateInputRef>();
const endInputRef = useRef<StandaloneDateInputRef>();
const isMobile = useMediaQuery({
maxWidth: MediaWidths.mobileL,
});
const shouldWrap = useContainerQuery({
maxWidth: MOBILE_WRAP_WIDTH,
targetRef: nodeRef,
});

// show button if it is mobile view
const withButton = _withButton || isMobile;

// =============================================================================
// EFFECTS
// =============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Default: StoryObj<Component> = {
hideInputKeyboard
/>
<Form.DateRangeInput
label="This has no action buttons on desktop viewports"
label="This has no action buttons"
withButton={false}
/>
<Form.DateRangeInput
Expand Down Expand Up @@ -100,7 +100,7 @@ export const WeekInput: StoryObj<Component> = {
}}
/>
<Form.DateRangeInput
label="This has no action buttons on desktop viewports"
label="This has no action buttons"
variant="week"
withButton={false}
/>
Expand Down Expand Up @@ -136,7 +136,7 @@ export const FixedRangeInput: StoryObj<Component> = {
numberOfDays={14}
/>
<Form.DateRangeInput
label="This has no action buttons on desktop viewports"
label="This has no action buttons"
variant="fixed-range"
withButton={false}
/>
Expand Down

0 comments on commit f1c18e7

Please sign in to comment.