On Tue, 4 Feb 2025 14:11:00 GMT, Ziad El Midaoui <d...@openjdk.org> wrote:
> When binding the promptTextProperty of a TextInputControl (TextField or > TextArea) to a text that contains linebreaks/newlines ("\n") the "bind" call > causes a RuntimeException to be thrown, the solution to it is to unbind > before calling the set(txt) method to set the new value for the property. > Also added tests to test this new fix In my opinion, both the original implementation, as well as the proposed fix, are defective. The implementation seems to try to enforce the (undocumented) invariant that the prompt text cannot contain line breaks. If that is indeed a sensible invariant, then the property should reject any attempt to set an invalid value by throwing an exception. Silently changing the property value is unexpected for developers. However, it doesn't seem to me that this is a sensible invariant. `TextFieldSkin` and `TextAreaSkin` render the prompt text with a `Text` node, which doesn't have a single-line restriction. Simply not doing anything to the prompt text would be a good choice. Another good choice would be to clean up the prompt text where it is used (i.e. in `TextFieldSkin` and `TextAreaSkin`). We already do this in other places, for example in `LabeledSkinBase::getCleanText`. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1694#issuecomment-2634274218