Topic: v-bind Datepicker min and max

NoahConn pro asked 2 years ago


Expected behavior

When I v-bind the min/max to a computed property, the min/max value will be updated after rendering based on the computed property

Actual behavior

When I v-bind the min/max to a computed property, the min/max value is never updated

Resources (screenshots, code snippets etc.)

<template>
  <MDBCol col="6">
    <MDBDatepicker 
      v-model="startDate"
      label="Start Date"
      placeholder="YYYY-MM-DD"
      :id="startID"
      format="YYYY-MM-DD"
      v-bind:max="startMax"
      @change="handleStartChange"
      @close="handleStartChange"
    /> 
  </MDBCol>
  <MDBCol col="6">
    <MDBDatepicker 
      v-model="endDate"
      label="End Date"
      placeholder="YYYY-MM-DD"
      :id="endID"
      format="YYYY-MM-DD"

      @change="handleEndChange"
      @close="handleEndChange"
    />
  </MDBCol>
</template>

<script>
import { MDBDatepicker, MDBCol } from 'mdb-vue-ui-kit'
import { computed, ref } from '@vue/reactivity'
export default {
  components:{
    MDBDatepicker, 
    MDBCol
  }, 
  props:{
    id: String,
    parentMax: String,
    index: Number
  }, 
  setup(props) {

    const startDate = ref()
    const endDate = ref()

    const startMax = computed(()=> {
      let startMax
      if(endDate.value){
        let max = endDate.value
        let maxArray = max.split('-')
        maxArray.reverse()
        startMax = maxArray.join('/')
      }
      return startMax
    })
    const endMin = computed(()=> {
      let endMin
      if(endDate.value){
        let min = endDate.value
        let minArray = min.split('-')
        minArray.reverse()
        endMin = minArray.join('/')
      }
      return endMin
    })

    const startID = props.id + '.start'
    const endID = props.id + '.end'

    return{
      startDate, endDate, startID, endID, startMax, endMin,
    }
  }
}
</script>

Mikołaj Smoleński staff commented 2 years ago

Thanks for posting an issue. I guess there could be a watcher for this props inside the component. We'll make a review.

Keep coding,  Mikołaj from MDB



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB Vue
  • MDB Version: MDB5 1.4.0
  • Device: Macbook Pro 2021
  • Browser: Chrome
  • OS: macOS Monterey
  • Provided sample code: No
  • Provided link: No