Skip to content

[3.0] Theme split (wave 4, part 8) — use the shared confirmation handler instead of inline onclick - #9393

Merged
live627 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/theme-you-sure
Aug 9, 2026
Merged

[3.0] Theme split (wave 4, part 8) — use the shared confirmation handler instead of inline onclick#9393
live627 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/theme-you-sure

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Part of the split of #7933, wave 4 part 8.

Four buttons still ask for confirmation with an inline handler, in two spellings:

onclick="return confirm(\'\');"
onclick="if (!confirm(\'\')) return false;"

script.js has carried a delegated .you_sure handler for exactly this, and most
of the forum already uses it — the error log, the calendar, the custom profile
field editor, the mark-all-as-read button. This moves the last four over, with the
message in data-confirm as everywhere else.

The shared handler also does something the inline calls do not:

// Check if the browser disabled the alert
if (!result && (timeAfter - timeBefore) < 10)
	return true;

If confirm() comes back false in under ten milliseconds it assumes the dialog
was suppressed by the browser and lets the action through, rather than the button
silently doing nothing. The inline versions have no such fallback.

file button
PersonalMessage.template.php delete selected, on the message index and on a conversation
PersonalMessage.template.php apply rules
ManageLanguages.template.php delete a language

Testing

Dispatched a real click at each button with window.confirm stubbed, and read
event.defaultPrevented after the delegated handler had run:

button declined accepted
PM → delete selected click blocked click proceeds
PM → apply rules click blocked navigates to …sa=manrules;apply

Both come out with class="button you_sure", the string in data-confirm, and no
onclick left.

Worth noting how that had to be measured: a stub that returns instantly is treated
by the handler as a suppressed dialog and the click goes through anyway. My first
attempt therefore "showed" that declining did nothing. The stub has to take longer
than the ten millisecond threshold before the result means anything.

The language delete button I have not exercised — it only appears once a second
language is installed, and I have one. It is the same one-line swap as the three
above.

Issues References (Fixes|Related|Closes)

Related to #7933

Four buttons ask for confirmation by hand, in two spellings:

    onclick="return confirm('…');"
    onclick="if (!confirm('…')) return false;"

script.js has carried a delegated .you_sure handler for this since long before
now, and most of the forum already uses it — the error log, the calendar, the
custom profile field editor. It also does something the inline calls do not: if
confirm() comes back false in under ten milliseconds it assumes the browser
suppressed the dialog and lets the action through, rather than silently doing
nothing.

Moves the last four over. The message travels in data-confirm, as elsewhere.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@live627
live627 merged commit df56876 into SimpleMachines:release-3.0 Aug 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants