1

I'm working on a project for a client where there needs to be 125 dropdown menus displayed on one page. I of course am not going to manually add all those so I wrote a simple for expression to do it for me. This works for the vast majority of the dropdown menus (which are just select tags), but some do not show up at all. And it is the same three each and every time. Why are these same three never being rendered? When looking in the Elements view in Chrome Dev Tools, it shows the dropdowns as being in the DOM, but they are not shown. I've looked at this code over and over and I cannot see anything wrong with it and need a second pair of eyes? What's going on here? (NOTE: db/get-all-advertisers never returns nil) Here is the code and a picture of what I'm talking about:

EDIT: Turns out this is some absolutely bizarre bug with the browsers or graphics or something on all of my Ubuntu machines. Was not able to replicate the bug on my friend's Mac. Everything worked fine.

(def new-issue-html
  (hiccup/html
   [:html
    [:head
     [:title "Add an Issue"]
     [:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}]
     [:link {:rel "stylesheet" :href "css/bootstrap.min.css"}]
     [:link {:rel "stylesheet" :href "css/extra.css"}]
     [:script {:src "js/field-verify.js"}]]
    (let [advertisers (db/get-all-advertisers)]
        [:body
         [:div {:class "container-fluid center"}
          [:h1 "Add an Issue"]
          (conj
           [:form {:method "post" :name "newIssueForm" :action "/new-issue"}
            [:div
             [:label {:for "issue-date"} "Issue Time Period (i.e. \"July/August 2020\"): "]]
            [:div
             [:input {:id "issue-date" :name "issue-date" :style "margin-bottom: 10px;"}]]]
           (for [num (range 1 (inc NUM_OF_ADVERTISERS_PER_ISSUE))
                 :let [ad-slot [:div
                                [:label {:style "margin-right: 10px;" :for (str "ad-slot-" num)} (str num ": ")]
                                (conj
                                 [:select {:id (str "ad-slot-" num) :name (str "ad-slot-" num)}]
                                 (for [advertiser advertisers
                                       :let [option [:option {:value (:advertisers/advertiser_id advertiser)}
                                                     (:advertisers/advertiser_name advertiser)]]]
                                   option))]]]
             ad-slot)
           (anti-forgery-field)
           [:div {:style "margin-top: 10px;"}
            (hf/submit-button {:id "submit" :onclick "return checkForm()"} "Create Issue")])]])]))

screenshot of the problem

TomLisankie
  • 3,785
  • 7
  • 28
  • 32

1 Answers1

0

You can wrap the fors in a doall to force realization of the lazy sequence

/edit:

It is possibly because of a Chromium bug related to GPU hardware acceleration and double monitors.. Many people experience a "Linux-only: Empty SELECT dropdown".

The bug thread states it is related to double monitors. A solution is to make the right monitor smaller than the left:

Different size monitors

Another (not successful for everyone) solution is according to this answer to disable hardware acceleration:

The summary is that you need to go to 'settings' then 'advanced settings' in Chrome, then uncheck the hardware acceleration box.

user2609980
  • 10,264
  • 15
  • 74
  • 143
  • That did not fix it either unfortunately. – TomLisankie Nov 16 '20 at 19:46
  • @TomLisankie Okay. It seems then that `(db/get-all-advertisers)` returns an empty list or `nil`. What you can also try, although it should not work at all then, is using `into` instead of `conj`. It will remove some nesting: `(conj [:select] [[:option]]) ;; => [:select [[:option]]]` versus `(into [:select] [[:option]]) ;; => [:select [:option]]`. Can you pass the result of `(db/get-all-advertisers)` in the question when things go wrong? – user2609980 Nov 17 '20 at 15:56