Skip to content

Fix this context in missing_role validation fix onClick handlers#1776

Merged
jenningsanderson merged 2 commits intocopilot/fix-unsafe-eval-bugfrom
copilot/fix-validation-issues
Mar 3, 2026
Merged

Fix this context in missing_role validation fix onClick handlers#1776
jenningsanderson merged 2 commits intocopilot/fix-unsafe-eval-bugfrom
copilot/fix-validation-issues

Conversation

Copy link

Copilot AI commented Mar 2, 2026

Quick fixes for missing_role validation (set as inner/outer, remove from relation) were broken — clicking them threw TypeError: can't access property "data", this.issue is undefined.

The onClick handlers were written as arrow functions, which capture this lexically (undefined in module scope) instead of binding to the ValidationFix instance at call time. Since entity_issues.js invokes them as d.onClick(), they need to be regular functions so this resolves to the ValidationFix instance (which has .issue set).

Change

modules/validations/missing_role.js — two handlers changed from arrow to regular functions:

// Before (broken): arrow function captures `this` from lexical scope → undefined
onClick: () => {
  const oldMember = this.issue.data.member;  // TypeError
  ...
}

// After (fixed): regular function receives `this` = ValidationFix instance
onClick: function() {
  const oldMember = this.issue.data.member;  // works correctly
  ...
}

Affects both the makeAddRoleFix handler (set as inner/outer) and the remove-from-relation handler.

Original prompt

This section details on the original issue you should resolve

<issue_title>Validation fixes are broken</issue_title>
<issue_description>### Description

the missing_role validation (and maybe others?) quick fixes don't work.

I suspect the issue was introduced in #961 which replaced the onClick function at https://github.com/facebook/Rapid/blob/main/modules/validations/missing_role.js#L95 with a => style func, which given the use of this seems problematic.

Screenshots

Image

Version

2.5.5

What browser are you seeing the problem on? What version are you running?

Firefox v141.0

The OS you're using

mac

Steps to reproduce

create a multipolygon relation and don't add inner/outer roles, when you click the fix to add inner or outer, nothing happens and you get an error in the console.

The browser URL at the time you encountered the bug

https://rapideditor.org/edit#map=20.82/37.50696/-77.43077&background=USGS-Imagery&id=r-1

The auto-detected useragent string for your browser (leave blank if you're manually filling this form out)

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: jenningsanderson <1637425+jenningsanderson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix validation fixes for missing_role functionality Fix this context in missing_role validation fix onClick handlers Mar 2, 2026
@jenningsanderson jenningsanderson changed the base branch from main to copilot/fix-unsafe-eval-bug March 3, 2026 17:31
@jenningsanderson jenningsanderson marked this pull request as ready for review March 3, 2026 17:31
@jenningsanderson jenningsanderson merged commit b720e97 into copilot/fix-unsafe-eval-bug Mar 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation fixes are broken

2 participants