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

Fix Text initialization and updating for TokenizingTextBox #4786

Conversation

michael-hawker
Copy link
Member

Fixes #4749

Addresses issues with how Text is handled with the TokenizingTextBox initialization and changes.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Initial text of the TokenizingTextBox was not being properly setup via an invalid binding. This would mean it would not clear when the clear method was called, nor could its initial text be set and appear in the box at runtime.

This could be reproduced in the Sample App

What is the new behavior?

  • Initial text is now properly set for the textbox
  • Changes to the text property are properly reflected in the inner box (e.g. clearing)
  • Initial text that has tokens delimited can now be used and will create tokens
  • Fixed regression (from the initial fix) where overwriting a token would not show initial typed character
  • Adds more tests (though not exhaustive, will wait for Labs infrastructure)
  • Fixes some local issues with building and running tests

image

PR Checklist

Please check if your PR fulfills the following requirements:

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@michael-hawker michael-hawker added bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ labels Oct 17, 2022
@michael-hawker michael-hawker added this to the 7.1.3 milestone Oct 17, 2022
@ghost
Copy link

ghost commented Oct 17, 2022

Thanks michael-hawker for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested a review from azchohfi October 17, 2022 23:53
@michael-hawker michael-hawker changed the title Llama/tokenizingtextbox fix4749 Fix Text initialization and updating for TokenizingTextBox Oct 17, 2022
@michael-hawker
Copy link
Member Author

Ah, right if I change the release stuff in the solution than it'll mess with the CI and try and build the sample app there too... will fix.

@michael-hawker michael-hawker force-pushed the llama/tokenizingtextbox-fix4749 branch from 1758c71 to 37d381f Compare October 18, 2022 06:41
@niels9001
Copy link

niels9001 commented Oct 18, 2022

@michael-hawker Tested the repro step you mentioned by setting the Textproperty of the TokenizingTextBox, and it seems to bind correctly!

@@ -89,7 +89,8 @@ private void ItemsSource_PropertyChanged(DependencyObject sender, DependencyProp
}
}

_currentTextEdit = _lastTextEdit = new PretokenStringContainer(true);
// Add our text box at the end of items and set it's default value to our initial text, fix for #4749

Choose a reason for hiding this comment

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

Super minor nit: its vs it's. So please ignore :)

(Don't set Release as that effects CI)
… use proper async tests

Also splits out Clear test into two separate tests.
…nityToolkit#4749

Think we maybe used to bind to the text directly, but there's no Text property directly on the TokenizingTextBoxItem, so this binding is meaningless. It doesn't effect the behavior of the textbox in practical usage, but somehow was doing something which was masking the problem for us to be able to detect within a test case.
Removing it to reduce confusion.

The text sync between the parent TokenizingTextBox collection of items (and the current edit) and the item is maintained through code-behind with text changing events. Though work is being done to resolve issues in this sync process. See issue CommunityToolkit#4749
Hook up initialization and change detection of parent Text property to update corresponding inner text of TokenizingTextBoxItem
Failing tests from previous commit now pass.
…g token wasn't being set to box (aggressive if)

Also realized we would no longer raise the text changed event in that scenario, so changed logic for text changed event.
We'll need to create integration tests for these keyboard driven scenarios in the new test setup from Labs (when it's finished) in 8.0. These would make good keyboard driver tests.
@michael-hawker michael-hawker force-pushed the llama/tokenizingtextbox-fix4749 branch from b8d4300 to cd1afd0 Compare October 18, 2022 16:30
@michael-hawker michael-hawker merged commit 2233ac6 into CommunityToolkit:main Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TokenizingTextBox Text property cannot be set manually from code behind in Release mode
2 participants