-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Textarea fields in usermods #4217
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please respect indentation of existing code.
Other consideration is that textarea
fields allow huge amounts of data to be entered by user. ESP is not well suited for such task and content may either be trimmed or rejected entirely. This may be baffling for users as it will work for some texts but not others.
I do not approve.
I agree, this needs to be done properly i.e. limit to a size that does not overflow any buffers. |
I think the usecase question from @DedeHai is a very valid point. a) it may create new issues, as the textblock must be copied into a buffer (stack?) for processing, it must be added to the global JSON object (heap), and then written out to cfg.json while preserving line breaks and special characters including b) how would I create such a text area for usermod settings? Today we typically do this in a usermod: uint8_t soundSquelch = 8;
void addToConfig(JsonObject& root) override {
JsonObject top = root.createNestedObject(FPSTR(_name));
JsonObject cfg = top.createNestedObject(FPSTR(_config));
cfg[F("squelch")] = soundSquelch;
}
bool readFromConfig(JsonObject& root) override {
JsonObject top = root[FPSTR(_name)];
bool configComplete = !top.isNull();
configComplete &= getJsonValue(top[FPSTR(_config)][F("squelch")], soundSquelch);
return configComplete; What's necessary to create a textarea? |
Good point about indentation. There's a mix of tabs and spaces in that chunk of the text file and I should take a closer look at how it's done here, I just trusted my text editor to figure it out. It's true that a lot of text could be entered in a textarea, but the same is true for My use case: I've got a usermod I'd like to contribute that uses a textarea for a reasonable string length, where the use of newlines to delimit makes it legible. You can see the usermod in action in #showcase on Discord, I just posted a clip a few minutes ago! I messed up this pull request in other ways than the tabs regardless (ended up making a new branch on main and not 0_15), and I should also include the npm-generated files, as well as an addition to the Example usermod... maybe a new pull request is in order! Will resubmit soonish and I hope I can win you over on the UI benefit of a tastefully used textarea ;) |
d8c7e99
to
d88f910
Compare
Didn't need to open a new pull request in the end, amended to fix the tabs/spaces issue @blazoncek pointed out, and put in an example as @softhack007 suggested. Looks like npm doesn't touch the stylesheet and the different branch doesn't matter in this case. Thanks all for the help and suggestions :) |
A textarea with a label ending in `>` will be presented as a textarea, allowing for multi-line text.
d88f910
to
8fd73c4
Compare
I do not see the benefit. While I like what you did in your usermod, would this be an acceptable workaround?
|
Sorry, I did this on accident. |
A textarea with a label ending in
>
will be presented as a textarea, allowing for multi-line text.It's a small change, I think it opens up possibilities for usermods that need more than just a single line but don't need their own custom settings page.