Skip to content

Conversation

@MattTheCuber
Copy link
Contributor

@MattTheCuber MattTheCuber commented Jan 7, 2025

Closes #3

Fixes value not being 2-way bound, does not fix input being triggered twice.

Tested here.

chrome_IO5KxNLy4e.mp4

);
this.editor.onDidChangeModelContent(() => {
this.$emit("update:modelValue", this.editor.getValue());
this.$emit("input", this.editor.getValue());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A solution for the double input event call would be to remove it in favor of just using the modeValue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

To skip the double update, just keep the last sent value in a local var and just skip the emit if same as before.

this.editor.onDidChangeModelContent(() => {
      const newValue = this.editor.getValue();
      if (this.lastValue === newValue) {
            return;
      }
      this.lastValue = newValue;
      this.$emit("update:modelValue", newValue);
      this.$emit("input", newValue);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This still seems to occur...

I set input="console.log($event)", and in the console it first prints the contents then and InputEvent.

@jourdain
Copy link
Collaborator

jourdain commented Jan 7, 2025

Thanks for the PR but now you are removing vue2 compatibility with v-model. Can you keep both value and modelValue? User should only use one of the 2, not both. That will allow v-model to work in vue2 and vue3.
That also mean, that you need to add value and ("model_value", "modelValue") in the properties list on the python side.

@jourdain jourdain self-requested a review January 7, 2025 19:41
@jourdain jourdain merged commit cc5329d into Kitware:master Jan 7, 2025
6 checks passed
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.

Editor value is not 2-way

2 participants