vikignt/svelte-mui

Textfield component proposed changes

sourcegr opened this issue · 3 comments

There are certain cases where it is important to show the help text, even though the Textfield is not focused, so that the user with just a glance will know exactly what should be typed in. This is especially true when there is an error; then the error message should always be visible.

There are also other cases, where an error message is needed, defined in the component props. I know we could do this programmaticaly, but I believe that defining it as a prop is more flexible.

So I edited your Textfield component and added

  • errormessage The string to display instead of the message in case the error is true
  • showmessage When this is present, the message (or error message) is always visible

You can see the changes here. You are free to incorporate any / all of these changes to the library, in any way you see fit, even changing the names of the variables etc.

Once again, thanks for a great piece of software

placeholder can be used as usual to show a help text without focused, but only when the value is empty

Yes you are right, but placeholder is not designed for this - actually I personally believe that it shouldn't be used.

for example, you create a password textarea, and you set

  • the message to "Min. 6 characters, alpha/numbers and -+_ are allowed"
  • the error would be

123$456 unsupported character

1234 Password should be at least 6 characters

123x-6 (No error, so we show the message to remind him of the valid chars because he may want to add more characters in there)

Now, add the "passwords don't match" in the mix, and you get the idea :)