-
Notifications
You must be signed in to change notification settings - Fork 58
Add "disable tag removal" setting #107
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
Conversation
have you tried setting the value attribute? |
"value" is broken for me, see #103 |
Ok I'll look into the other issue in detail when I find some time, hopefully soon. Let me try to understand the use case here. What do you mean by read-only form? It's a form with a predefined value that the user can't change, but it still gets submitted to the server? If the answer is yes, then fixing #103 plus using
can you elaborate on this please? Thanks |
Sure, I'll explain. I could not make "sticky" work well with assocs/embeds - the |
Thanks for the explanation. I haven't suggested anything yet. Here's my actual suggestion: to use the If |
Yes I am aware of the "disabled" attribute, however you explicitly stated in the docs that it affects only the text input. I think if you suddenly make it also disable tag removal, it may break some user's code that depended on the current behavior. That's why I chose to create a new attribute. There could be cases where you want to disallow adding new tags, but still allow removing existing tags. I'm not sure about it, but it's a possibility Regarding #103 - I've stopped using that setting, as I don't need it. It works just fine with the form values OOTB |
The docs are wrong/incomplete :) And this conversation got me thinking that there is a difference between disabled and readonly: disabled means the user can't interact with the input AND the value isn't submitted when the form is. Readonly simply means the user can't interact with the input. I feel it would be nice to provide both, although I just saw that the HTML |
Are they ? |
No, because I made sure that the button to clear the tags and the selection now honor the |
I would also add disabled state check in the event handlers (like in my PR), just to be sure. Not that it's a good idea to trust form data but maybe someone is doing that... wouldn't hurt anyway |
You mean raising if someone sends If someone is doing that than they're explicitly sending them from the front-end, bypassing the component UI. They're "not "supposed" to do that. They're messing with the internal details of the component and so I don't feel like we have to guarantee anything. |
Exactly, it is to prevent forbidden actions by an malicious actor. |
We're talking about 2 events here: If the UI of the component isn't sending them, I don't feel like I have to worry about a developer sending them explicitly from their code. If they're doing so, they're meddling with the internal state of the component and there's nothing I can or should do to protect them |
You don't have to worry, sure. It's just the attitude - doing the bare minimum or going above and beyond. |
No, it's about understanding the meaning of clear contracts and interfaces. You don't mess with the internal implementation of a software component. You use the interface. If you want to mess with the internal state, you can do it, but you should know that you're on your own. Trying to add protection or error handling there is both (1) useless and (2) hopelessly defensive, because no amount of protection will be enough |
I'm gonna close this MR now, thanks for the fruitful interaction |
What contracts are you talking about if we are talking about malicious actor ? What you are saying doesn't make any sense. Besides, nobody would get hurt if you added those checks. It's not a rational decision |
I would invite you to use a more respectful tone. I guarantee you you have only to gain from it.
The contract I'm talking about is the fact that these events are internal to the component and are not part of any user interface. If you send them, it means you've read the code and your trying things out, which is perfectly ok but again, you should expect things to break when doing so. A malicious actor here can only be someone who performed a successful XSS attack on the page, and in this case, all bets are off, no amount of protection (certainly not raising an exception in an event handler) will be enough. |
A malicious actor is a user sending unexpected data in WS messages (remember we always should treat data coming from the client as untrusted). It's not the owner of the website/application or a user who is following contracts. |
I know. And you'd be 100% right in adding a check here if these messages had any effect on the backend. But, they only affect the frontend, which is inherently (as you correctly point out) untrusted.
No developer using LiveSelect according to the docs is supposed to send those message, so I don't feel the need to raise special error messages in that case. Otherwise, the whole component would be full of those checks.
|
This adds a new component setting which allows to disable removal of currently selected tags. With this setting on one can implement "read only" forms.
Currently LS has "sticky" attribute for options but its purpose is to lock a single option, and I couldn't make it work well with assocs/embeds - it's honestly too much work if all you need is "read only" mode. Besides, this new option prevents removal on the event callback level too.