Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash accessing event.srcElement under Firefox when keyboard used while editing #751

Closed
pastcompute opened this issue Mar 11, 2018 · 1 comment

Comments

@pastcompute
Copy link
Contributor

mapbox-gl-js version: 0.43.2 but almost certainly any
mapbox-gl-draw version: 1.05, git:master

Steps to Trigger Behavior

  1. Use the draw controls
  2. Press a key while editing a polygin

Expected Behavior

Either nothing, or an action related to the current mode

Actual Behavior

Stacktrace:

Caught a global error: message=event.srcElement is undefined
customError.ts:5:4
ERROR 
TypeError
​
columnNumber: 1
​
fileName: "http://localhost:8100/build/vendor.js"
​
lineNumber: 186433
​
message: "event.srcElement is undefined"
​
stack: "module.exports/events.keydown@http://localhost:8100/build/vendor.js:186433:1\nF</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15649\nonInvokeTask@http://localhost:8100/build/vendor.js:5114:24\nF</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15562\nF</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10815\nF</h</e.invokeTask@http://localhost:8100/build/polyfills.js:3:16787\np@http://localhost:8100/build/polyfills.js:2:27646\nv@http://localhost:8100/build/polyfills.js:2:27893\n"
​
__proto__: Object { stack: "", … }

which I tracked down to the following code in src/events.js :

  events.keydown = function(event) {
    if (event.srcElement.classList[0] !== 'mapboxgl-canvas') return; // we only handle events on the map

    if ((event.keyCode === 8 || event.keyCode === 46) && ctx.options.controls.trash) {

but srcElement is not recognised on Firefox: see https://developer.mozilla.org/en-US/docs/Web/API/Event/srcElement

I have a patch, will submit shortly.

@pastcompute
Copy link
Contributor Author

See also similar issues, e.g. Dash-Industry-Forum/dash.js#590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant