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

Add fix for display text on multiline text block #4454

Merged
merged 1 commit into from Nov 17, 2020

Conversation

moniika
Copy link
Contributor

@moniika moniika commented Nov 17, 2020

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

n/a

Proposed Changes

Fixed logic in getDisplayText_ for FieldMultilineText to use getText rather than this.value_ directly.

Reason for Changes

Due to the logic in getDisplayText_, rendering of editor text for FieldMultilineText was acting up in cases where the validator returned a string of different size. This is because there is extra logic in getText that returns the editor text if the field is currently being edited.

Before change:
cfe96abb-4a24-4fe4-aaca-66e711c3efdf

After change:
d35ff7e9-e099-4213-a707-8d598f5922e4

Test Coverage

Tested block with FieldMultilineInput and custom validator before and after change:

Blockly.Blocks['text_multiline_validator'] = {
  init: function() {
    this.appendDummyInput()
        .appendField('multiline text input:')
        .appendField(
            new Blockly.FieldMultilineInput('default', this.validate), 'INPUT');
    this.setColour('#5ba58c');
  },

  validate: function(newValue) {
    return newValue.replace(/a/gm, '');
  },
};

Tested on:

Additional Information

Issue found while writing documentation for multiline text field

@moniika moniika merged commit e6cdbf9 into google:develop Nov 17, 2020
@moniika moniika deleted the multi-validator branch December 2, 2020 22:10
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.

None yet

2 participants