Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/baredom/components/x_combobox/x_combobox.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
"[part=chevron]{"
"display:inline-flex;align-items:center;"
"color:var(--x-combobox-chevron-color);flex-shrink:0;margin-left:0.25rem;"
"transition:transform 200ms ease;pointer-events:none;"
"transition:transform 200ms ease;cursor:pointer;"
"}"
":host([open]) [part=chevron]{transform:rotate(180deg);}"
"[part=panel]{"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"flex-shrink:0;"
"margin-left:0.25rem;"
"transition:transform 200ms ease;"
"pointer-events:none;"
"cursor:pointer;"
"}"
":host([open]) [part=chevron]{"
"transform:rotate(180deg);"
Expand Down
29 changes: 29 additions & 0 deletions test/baredom/components/x_combobox/x_combobox_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,35 @@
(is (some? (shadow-part el "[part=chevron]")))
(is (some? (shadow-part el "[part=panel]")))))

;; ── Chevron is hit-testable (regression: issue #267) ─────────────────────────
;; The chevron carries a `pointerdown` listener that toggles the panel. If CSS
;; sets `pointer-events:none` on it, real clicks fall through and the handler is
;; dead code. A synthetic dispatchEvent bypasses hit-testing, so we assert the
;; computed style directly — this is what actually caught the bug.
(deftest chevron-is-hit-testable-test
(let [^js el (append! (make-el))
^js chevron (shadow-part el "[part=chevron]")
pe (.-pointerEvents (js/getComputedStyle chevron))]
(is (not= "none" pe)
"chevron must receive pointer events so its click handler can fire")))

;; ── Chevron pointerdown toggles the panel (issue #267) ───────────────────────
(deftest chevron-pointerdown-toggles-open-test
(let [^js el (append! (make-el))
^js chevron (shadow-part el "[part=chevron]")
fire! (fn []
(.dispatchEvent
chevron
(js/PointerEvent. "pointerdown"
#js {:bubbles true :cancelable true})))]
(is (not (.hasAttribute el model/attr-open)))
(fire!)
(is (.hasAttribute el model/attr-open)
"pointerdown on the chevron should open the panel")
(fire!)
(is (not (.hasAttribute el model/attr-open))
"pointerdown on the chevron while open should close the panel")))

;; ── Default state ────────────────────────────────────────────────────────────
(deftest default-state-test
(let [^js el (append! (make-el))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@
(is (some? (shadow-part el "[part=chevron]")))
(is (some? (shadow-part el "[part=panel]")))))

;; ── Chevron is hit-testable (regression: issue #267) ─────────────────────────
;; The chevron carries a `pointerdown` listener that toggles the panel. If CSS
;; sets `pointer-events:none` on it, real clicks fall through and the handler is
;; dead code. A synthetic dispatchEvent bypasses hit-testing, so we assert the
;; computed style directly — this is what actually caught the bug.
(deftest chevron-is-hit-testable-test
(let [^js el (append! (make-el))
^js chevron (shadow-part el "[part=chevron]")
pe (.-pointerEvents (js/getComputedStyle chevron))]
(is (not= "none" pe)
"chevron must receive pointer events so its click handler can fire")))

;; ── Chevron pointerdown toggles the panel (issue #267) ───────────────────────
(deftest chevron-pointerdown-toggles-open-test
(let [^js el (append! (make-el))
^js chevron (shadow-part el "[part=chevron]")
fire! (fn []
(.dispatchEvent
chevron
(js/PointerEvent. "pointerdown"
#js {:bubbles true :cancelable true})))]
(is (not (.hasAttribute el model/attr-open)))
(fire!)
(is (.hasAttribute el model/attr-open)
"pointerdown on the chevron should open the panel")
(fire!)
(is (not (.hasAttribute el model/attr-open))
"pointerdown on the chevron while open should close the panel")))

;; ── Default state ────────────────────────────────────────────────────────────
(deftest default-state-test
(let [^js el (append! (make-el))
Expand Down