loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix unclickable checkboxes (#30195)

Fix https://github.com/go-gitea/gitea/issues/30185, regression from
https://github.com/go-gitea/gitea/pull/30162.

The checkboxes were unclickable because the label was positioned over
the checkbox with `padding`. Now it uses `margin` so the checkbox itself
will be clickable in all cases.

Secondly, I changed the for/id linking to also add missing `for`
attributes when `id` is present. The other way around (only `for`
present) is currently not handled and I think there are likey no
occurences in the code and introducing new non-generated `id`s might
cause problems elsewhere if we do, so I skipped on that.

(cherry picked from commit 640850e15f56bbe01f5d8ea407f99c79dc38457e)

authored by

silverwind and committed by
Gergely Nagy
fbca0dd9 25303b2d

+14 -5
+1 -1
web_src/css/modules/checkbox.css
··· 41 41 42 42 .ui.checkbox label, 43 43 .ui.radio.checkbox label { 44 - padding-left: 1.85714em; 44 + margin-left: 1.85714em; 45 45 } 46 46 47 47 .ui.checkbox + label {
+13 -4
web_src/js/modules/fomantic/checkbox.js
··· 6 6 if (el.hasAttribute('data-checkbox-patched')) continue; 7 7 const label = el.querySelector('label'); 8 8 const input = el.querySelector('input'); 9 - if (!label || !input || input.getAttribute('id') || label.getAttribute('for')) continue; 10 - const id = generateAriaId(); 11 - input.setAttribute('id', id); 12 - label.setAttribute('for', id); 9 + if (!label || !input) continue; 10 + const inputId = input.getAttribute('id'); 11 + const labelFor = label.getAttribute('for'); 12 + 13 + if (inputId && !labelFor) { // missing "for" 14 + label.setAttribute('for', inputId); 15 + } else if (!inputId && !labelFor) { // missing both "id" and "for" 16 + const id = generateAriaId(); 17 + input.setAttribute('id', id); 18 + label.setAttribute('for', id); 19 + } else { 20 + continue; 21 + } 13 22 el.setAttribute('data-checkbox-patched', 'true'); 14 23 } 15 24 }