nitrogen_core icon indicating copy to clipboard operation
nitrogen_core copied to clipboard

Textbox_autocomplete error and simple bridge question

Open th31nitiate opened this issue 2 years ago • 0 comments

Hey,

I found this simple issue in the textbox_autocomplete section. I say simple because it don't seem to complex to resolve. The source of the issue might be because I'm using the rebar3 version of nitrogen.

--- a/src/handlers/query/default_query_handler.erl
+++ b/src/handlers/query/default_query_handler.erl
@@ -55,8 +55,10 @@ set_websocket_params(Params, _Config, State) ->
 get_value(Path, Config, State) ->
     case get_values(Path, Config, State) of
         [] -> undefined;
-        [One] -> 
+        [[],One] -> 
             wf:to_unicode_list(One);
+       One ->
+             wf:to_unicode_list(One);
         _Many -> throw({?MODULE, too_many_matches, Path})
     end.

It seems to be just a minor change in how the data is represented in other parts of the program that causes these issues. I also had another question regarding what you mean by It's worth considering reworking this page to use simple_bridge for all the query and post parameter evaluation from the TODO comment in the file.

It appears to me that the file is using simple bridge for most things:

init(_Config, _State) ->
% Get query params and post params
% from the request bridge...
Bridge = wf_context:bridge(),
QueryParams = sbw:query_params(Bridge),
PostParams = sbw:post_params(Bridge),

% Load into state...
Params = QueryParams ++ PostParams,

I'm not sure if I can help much with this part as I'm yet to fully read the simple_bridge readme doc. Though as I say looking at the file it seems as though it's making use of simple bridge.


I guess the code I added there seems to have a logic error. Both One and _Many in the case statement are basically the same thing. I'm wondering what type of error scenario/input were you expecting for the _Many clause ?

th31nitiate avatar Oct 14 '23 16:10 th31nitiate