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

Date can still be changed in readonly mode #133

Open
ahmetemrekilinc opened this issue Feb 17, 2017 · 4 comments
Open

Date can still be changed in readonly mode #133

ahmetemrekilinc opened this issue Feb 17, 2017 · 4 comments

Comments

@ahmetemrekilinc
Copy link

If readonly is set true, the input text cannot be changed, however onclick date can still be changed.

@duizendnegen
Copy link
Contributor

duizendnegen commented Feb 17, 2017 via email

@fkm
Copy link

fkm commented May 22, 2019

Is that design choice documented somewhere? I couldn't find it in the Pikaday readme.

Having a datepicker on a read-only field (especially as it can still change the displayed input value) doesn't make any sense to me. Please enlighten me.

@cincodenada
Copy link

cincodenada commented May 26, 2021

ember-pikaday could work around this, but this is really an upstream issue, and there's an issue open that could always use some more thumbs-up (or PRs!): Pikaday/Pikaday#662

There's also a workaround in that thread, which I've adapted to ember-pikaday for my needs. I'm already extending the component, but if you don't want to extend, I haven't tested this, but you may be able to accomplish this with reopenClass()

import PikadayInput from 'ember-pikaday/components/pikaday-input'
import { computed } from '@ember/object'

export default PikadayInput.extend({
  // Prevent opening the date box in readonly mode, adapted from workaround on
  // https://github.com/Pikaday/Pikaday/issues/662
  onOpen: computed(function () {
    // This is a computed because we need `this`, and simply setting this
    // property to a function (arrow or not) doesn't get us that
    return () => {
      if (this.element.readOnly) { return this.get('pikaday').hide() }
    }
  })
})

@fkm
Copy link

fkm commented May 26, 2021

Thank you for your response!

I've stopped working with Ember but I'm sure this will help someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants