Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime segments allow entering values beyond the min/max limits #138

Open
logaretm opened this issue Feb 23, 2025 · 0 comments
Open

DateTime segments allow entering values beyond the min/max limits #138

logaretm opened this issue Feb 23, 2025 · 0 comments
Assignees
Labels
🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project

Comments

@logaretm
Copy link
Member

logaretm commented Feb 23, 2025

What

Provided a date field with a min/max props, the date segments are properly limited with arrow up/down key events, but when entering a value manually, the min/max are not respected.

<script setup lang="ts">
import DateField from '@/components/DateField.vue';

const min = new Date(2025, 0, 4, 0, 0, 0, 0);
const value = new Date('2025-01-15');
const max = new Date('2025-01-20');
</script>

<template>
    <DateField name="birthdate" label="Birth Date" :value="value" :min="min" :max="max" />
</template>

The tricky part here is we could only prevent date entry in certain scenario: When the month and year is known beforehand. This is possible if min/max have the same month AND year values. (i.e: When the user only has to enter 1 segment to complete the date).

If the min/max allows for more than one enterable segment, then this breaks down as the order of entry is not reliable and the possible values depends heavily on the most significant segment (month/year).

Alternatively we could emit a validation error when that happens, but that error won't be translatable which follows the HTML rules behavior in other components. Maybe this is a quick fix that is worthwhile.

This can be alleviated partially with #139

@logaretm logaretm added ❗️ p1-high Important tasks or features with significant impact on users or the project 🐞 bug Something isn't working labels Feb 23, 2025
@logaretm logaretm self-assigned this Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant