Skip to content

Commit

Permalink
Merge pull request #1054 from PrefectHQ/date-range-select-tweaks
Browse files Browse the repository at this point in the history
Enhancement: PDateRangeSelect overflow and escape to close
  • Loading branch information
pleek91 authored Dec 13, 2023
2 parents 4b59d1d + 16f8a5c commit 1d99a80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/DateRangePicker/PDateRangePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
}
.p-date-range-picker__date-wrapper--selected-start { @apply
rounded-l-sm
rounded-l-default
}
.p-date-range-picker__date-wrapper--selected-start::before { @apply
Expand All @@ -193,7 +193,7 @@
}
.p-date-range-picker__date-wrapper--selected-end { @apply
rounded-r-sm
rounded-r-default
}
.p-date-range-picker__date-wrapper--in-range { @apply
Expand Down
8 changes: 6 additions & 2 deletions src/components/DateRangeSelect/PDateRangeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</template>

<script lang="ts" setup>
import { useKeyDown } from '@prefecthq/vue-compositions'
import { addDays, addSeconds, differenceInSeconds, isAfter, isBefore, secondsInDay, startOfMinute } from 'date-fns'
import { computed, ref, watch } from 'vue'
import PButton from '@/components/Button/PButton.vue'
Expand Down Expand Up @@ -67,6 +68,10 @@
'update:modelValue': [DateRangeSelectValue],
}>()
useKeyDown('Escape', () => {
popover.value?.close()
})
const placement = [bottomLeft, topLeft, bottomRight, topRight, leftInside, rightInside]
const popover = ref<InstanceType<typeof PPopOver>>()
const mode = ref<'relative' | 'range'>('relative')
Expand Down Expand Up @@ -252,7 +257,6 @@

<style>
.p-date-range-select { @apply
w-full
flex
flex-nowrap
items-center
Expand All @@ -277,6 +281,7 @@
}
.p-date-range-select__input { @apply
overflow-hidden
grow
shrink
min-w-0
Expand All @@ -293,7 +298,6 @@
.p-date-range-select__label { @apply
shrink
min-w-0
overflow-hidden
whitespace-nowrap
}
Expand Down

0 comments on commit 1d99a80

Please sign in to comment.