Skip to content

Commit

Permalink
fix: Inline time-picker with is-24="false" overflowing the contai…
Browse files Browse the repository at this point in the history
…ner (fixes #990)
  • Loading branch information
Jasenkoo committed Oct 17, 2024
1 parent c22287b commit 916eb31
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
23 changes: 20 additions & 3 deletions src/VueDatePicker/components/TimePicker/TimeInput.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<div v-if="!disabled" class="dp__time_input">
<div v-for="(timeInput, i) in timeInputs" :key="i" :class="timeColClass">
<div
v-for="(timeInput, i) in timeInputs"
:key="i"
:class="timeColClass"
:data-compact="isCompact && !enableSeconds"
:data-collapsed="isCompact && enableSeconds"
>
<template v-if="timeInput.separator"> <template v-if="!timeOverlayOpen">:</template> </template>
<template v-else>
<button
Expand Down Expand Up @@ -115,6 +121,7 @@
role="button"
:aria-label="defaultedAriaLabels?.amPmButton"
tabindex="0"
:data-compact="isCompact"
@click="setAmPm"
@keydown="checkKeyDown($event, () => setAmPm(), true)"
>
Expand Down Expand Up @@ -212,8 +219,14 @@
});
const { setTimePickerElements, setTimePickerBackRef } = useArrowNavigation();
const { defaultedAriaLabels, defaultedTransitions, defaultedFilters, defaultedConfig, defaultedRange } =
useDefaults(props);
const {
defaultedAriaLabels,
defaultedTransitions,
defaultedFilters,
defaultedConfig,
defaultedRange,
defaultedMultiCalendars,
} = useDefaults(props);
const { transitionName, showTransition } = useTransitions(defaultedTransitions);
Expand Down Expand Up @@ -287,6 +300,10 @@
}),
);
const isCompact = computed(
() => props.timePickerInline && defaultedRange.value.enabled && !defaultedMultiCalendars.value.count,
);
const timeInputs = computed((): TimeInput[] => {
const inputs = [{ type: 'hours' }];
if (props.enableMinutes) {
Expand Down
2 changes: 1 addition & 1 deletion src/VueDatePicker/style/components/_SelectionOverlay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
padding: 0;
box-sizing: border-box;
display: flex;
margin-inline: auto auto;
margin-inline: auto;
flex-wrap: wrap;
max-width: 100%;
width: 100%;
Expand Down
12 changes: 12 additions & 0 deletions src/VueDatePicker/style/components/_TimeInput.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

.dp__time_col_reg_with_button {
padding: 0 15px;

&[data-compact~="true"] {
padding: 0 5px;
}
}

.dp__time_col_sec {
Expand All @@ -32,6 +36,10 @@

.dp__time_col_sec_with_button {
padding: 0 5px;

&[data-collapsed~="true"] {
padding: 0;
}
}

.dp__time_col {
Expand Down Expand Up @@ -133,6 +141,10 @@
padding: var(--dp-common-padding);
border-radius: var(--dp-border-radius);
cursor: pointer;

&[data-compact~="true"] {
padding: 7px;
}
}

.dp__tp_inline_btn_bar {
Expand Down

0 comments on commit 916eb31

Please sign in to comment.