bbovenzi commented on code in PR #40744:
URL: https://github.com/apache/airflow/pull/40744#discussion_r1827773439


##########
airflow/www/static/js/dags.js:
##########
@@ -140,7 +146,21 @@ $(".typeahead").typeahead({
       window.location = `${gridUrl.replace("__DAG_ID__", 
value.name)}?${query}`;
     }
   },
-});
+  appendTo: "#search_form > div"
+}).data("ui-autocomplete")._renderMenu = function(ul, items) {
+  ul.addClass("typeahead dropdown-menu");
+  var that = this;

Review Comment:
   First, this should be a `let` but second, why are we even creating `that` in 
the first place? Let's just use `this`



##########
airflow/www/static/js/dags.js:
##########
@@ -116,21 +116,27 @@ $.each($("[id^=toggle]"), function toggleId() {
   });
 });
 
-$(".typeahead").typeahead({
-  source(query, callback) {
-    return $.ajax(autocompleteUrl, {
+// eslint-disable-next-line no-underscore-dangle
+$(".typeahead").autocomplete({
+  autoFocus:true,
+  source: (request, response)=> {
+    $.ajax({
+      url: autocompleteUrl,
       data: {
-        query: encodeURIComponent(query),
+        query: encodeURIComponent(request.term),
         status: statusFilter,
       },
-      success: callback,
+      success: (data)=> {
+        response(data);
+      }
     });
   },
-  displayText(value) {
-    return value.dag_display_name || value.name;
+  focus: (event, ui)=> {
+    // Prevents value from being inserted on focus
+    event.preventDefault();
   },
-  autoSelect: false,
-  afterSelect(value) {
+  select: (event, ui)=> {

Review Comment:
   ```suggestion
     select: (_, ui)=> {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to