Skip to content

fix(MdInput): Avoid InputEvent object from @input event #1196

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

Merged
merged 9 commits into from
Nov 27, 2017
Merged

fix(MdInput): Avoid InputEvent object from @input event #1196

merged 9 commits into from
Nov 27, 2017

Conversation

VdustR
Copy link
Member

@VdustR VdustR commented Nov 22, 2017

fix #1160

Related to Vue#6846, #7042.

After studying #7042#issuecomment-344948474, I tried:

<input type='text' v-model='model' v-bind='$attrs' 
  v-on="{
    ...$listeners,
    input: event => $emit('input', event.target.value)
  }">

and it works.

Demo: Codepen

@marcosmoura
Copy link
Member

THAT'S AWESOME!
Can I ask you one more thing? This fix will make possible to have a non-required v-model on input, textarea, select and file.
Would you mind to improve this too?

@marcosmoura marcosmoura self-requested a review November 22, 2017 16:04
@VdustR
Copy link
Member Author

VdustR commented Nov 22, 2017

I'll do my best.

@VdustR
Copy link
Member Author

VdustR commented Nov 23, 2017

@marcosmoura Excuse me. How to resolve netlify deploy preview failed?

I checked the details and it showed page not found to me.

@VdustR
Copy link
Member Author

VdustR commented Nov 23, 2017

  • fix(MdField): $emit missing this
  • fix(MdSelect): declare all MdSelect properties in data() and make MdSelect.modelValue synced with model
  • feat(MdField): make 'v-model'/'value' in MdFile, MdInput, MdSelect, MdTextarea optional
  • feat(MdSelect): one direction update with :value
    one-way-value

@VdustR
Copy link
Member Author

VdustR commented Nov 23, 2017

@@ -1,7 +1,7 @@
export default {
props: {
value: {
required: true
default: null
Copy link
Member

@marcosmoura marcosmoura Nov 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better approach to this is value: {}
This will allow any type.

this.setFieldValue()
},
setMultipleContentByValue () {
if (!this.localValue) this.initialLocalValueByDefault()
Copy link
Member

@marcosmoura marcosmoura Nov 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To improve code style, change this if to be inside brackets:
if ( ... ) {
...
}

Copy link
Member

@marcosmoura marcosmoura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!
Just some minor issues with code style

@marcosmoura marcosmoura merged commit 12a4219 into vuematerial:dev Nov 27, 2017
marcosmoura pushed a commit that referenced this pull request Nov 28, 2017
* origin/dev:
  docs: add note for themes, example with CDNs (#1225)
  fix(MdProgressSpinner): fix firefox radius (#1221)
  fix(MdDatepicker): show today if date is not selected (#1214)
  fix(MdInput): avoid InputEvent object from @input event (#1196)
  docs: change old repository name to new (#1216)
  fix(MdAutocomplete): sync v-model with search term  (#1218)
  chore: add codesponsor again
  Update README.md
  Revert "fix(MdChips): make chip allow spaces (#1211)"
  Revert "fix: remove global scoped css affecting all md-content elements"
  chore: remove codesponsor because github is a bad guy!
  chore: remove codesponsor because github is a bad guy!
  fix: remove global scoped css affecting all md-content elements
  chore: remove async attribute
  fix(MdChips): make chip allow spaces (#1211)
  docs(Codepen): Fix codepen style undefined (#1202)
  Updated file doc. Typo in event name md-change (#1192)
  Revert "build: generate beta 5"
  docs: improve drastically the initial load of documentation
@VdustR VdustR deleted the fix#1160 branch November 29, 2017 03:18
dev-arrow added a commit to dev-arrow/vue-material that referenced this pull request Nov 25, 2024
* fix(MdInput): Avoid InputEvent object from @input event

fix #1160

* fix(MdField): `$emit` missing `this`

* fix(MdSelect): declare all MdSelect properties in `data()` and make `MdSelect.modelValue` synced wit

* feat(MdField): make 'v-model'/'value' in MdFile, MdInput, MdSelect, MdTextarea optional

`MdSelect` could be switched between single and multiple

fix #1150

* feat(MdSelect): one way update with `value`

* fix(MdOption): let value avaiable to be `0`

fix #1203

* fix(MdField): set value default as null

* fix(MdField): Remove value default

vuematerial/vue-material#1196 (comment)

* style(MdSelect): brackets for if statement execute block

vuematerial/vue-material#1196 (comment)
wakeup0706 added a commit to wakeup0706/vue-material that referenced this pull request Feb 13, 2025
* fix(MdInput): Avoid InputEvent object from @input event

fix #1160

* fix(MdField): `$emit` missing `this`

* fix(MdSelect): declare all MdSelect properties in `data()` and make `MdSelect.modelValue` synced wit

* feat(MdField): make 'v-model'/'value' in MdFile, MdInput, MdSelect, MdTextarea optional

`MdSelect` could be switched between single and multiple

fix #1150

* feat(MdSelect): one way update with `value`

* fix(MdOption): let value avaiable to be `0`

fix #1203

* fix(MdField): set value default as null

* fix(MdField): Remove value default

vuematerial/vue-material#1196 (comment)

* style(MdSelect): brackets for if statement execute block

vuematerial/vue-material#1196 (comment)
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

Successfully merging this pull request may close these issues.

[mdField] keydown.enter sometimes got InputEvent object as it's v-model value
2 participants