-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
pointerEvents="none" doesn't work for all SVG elements, weird behaviour for the SVG elements touch accessibility #1290
Comments
Is this library still maintained? Looks like no... |
I'm too busy at work at the moment. Feel free to step in and make a pr with a fix. This library is certainly in need of more maintainers. |
Hello @msand, it's OK, just it was interesting for me if it still maintained. |
Hmm yeah, we use
Seems to be from here: https://github.com/facebook/react-native/blob/master/React/Views/RCTViewManager.m#L248 So I guess we need to implement |
@oleksandr-dziuban I realised for our use case it was enough to do e.g. const pointerEvents = Platform.OS === 'android' ? {pointerEvents: 'box-none'} : null;
return <G {...pointerEvents}> ... </G> Your use case seems different though. There is also another bug preventing onPress from working on iOS which is to do with scale transforms 🤔 Will create a reproduction / submit a new bug report later today or tomorrow. |
@mjmasn Hi, for me even the Android doesn't work |
Hi @msand , I see some activity in this repo, maybe you have 30 mins to check this issue, could you please check, because our project is blocked because of this issue in 4 places... Thank you |
@oleksandr-dziuban Can you try the latest commit from the develop branch? I'm not sure what else will break because of this change. Especially with regards to gesture responders. |
Ok, will do in a hour, thanks a lot, and sorry for interruption |
…handling" This reverts commit 11d14fd.
This reverts commit bd78998.
@msand I have checked latest develop code. I'm using PanResponder events system and there is no changes when I apply pointerEvents="none" or "box-none" on iOS. Just we don't have error now that "box-none" value us not supported. On Android application is crashing when I try to load use pointerEvents property |
Hmm, strange, for me all three of your examples work. Did you rebuild the native code? |
@msand Yes, I have rebuilt it yes... Looks like a few guys have same issues |
import * as React from 'react';
import Svg, {Rect, Image, G} from 'react-native-svg';
export default class App extends React.Component {
render() {
return (
<Svg viewBox="0 0 500 500">
<G>
<G>
<Image
onPress={() => {
alert('<Image> onPress');
}}
x={50}
y={50}
width={400}
height={400}
href={{
uri:
'https://interactive-examples.mdn.mozilla.net/media/examples/grapefruit-slice-332-332.jpg',
}}
/>
</G>
<G pointerEvents="none">
<Rect
pointerEvents="none"
x={0}
y={0}
width={500}
height={500}
strokeWidth={10}
stroke="#ccc"
fill="transparent"
/>
</G>
</G>
</Svg>
);
}
} |
import * as React from 'react';
import Svg, {Rect, Image, G} from 'react-native-svg';
export default class App extends React.Component {
render() {
return (
<Svg viewBox="0 0 500 500">
<G>
<G>
<Image
onStartShouldSetResponder={() => true}
onMoveShouldSetResponder={() => true}
onMoveShouldSetPanResponderCapture={() => true}
onStartShouldSetPanResponderCapture={() => true}
onResponderGrant={() => alert('<Image> Grant')}
onResponderMove={() => alert('<Image> Move')}
x={50}
y={50}
width={400}
height={400}
href={{
uri:
'https://interactive-examples.mdn.mozilla.net/media/examples/grapefruit-slice-332-332.jpg',
}}
/>
</G>
<G pointerEvents="none">
<Rect
pointerEvents="none"
onStartShouldSetResponder={() => false}
onMoveShouldSetResponder={() => false}
onResponderGrant={() => alert('<Rect> Grant')}
onResponderMove={() => alert('<Rect> Move')}
x={0}
y={0}
width={500}
height={500}
strokeWidth={10}
stroke="#ccc"
fill="transparent"
/>
</G>
</G>
</Svg>
);
}
} |
import * as React from 'react';
import Svg, {Line, Image, G} from 'react-native-svg';
export default class App extends React.Component {
render() {
return (
<Svg viewBox="0 0 500 500">
<G>
<G>
<Image
onStartShouldSetResponder={() => true}
onMoveShouldSetResponder={() => true}
onMoveShouldSetPanResponderCapture={() => true}
onStartShouldSetPanResponderCapture={() => true}
onResponderGrant={() => alert('<Image> Grant')}
onResponderMove={() => alert('<Image> Move')}
x={50}
y={50}
width={400}
height={400}
href={{
uri:
'https://interactive-examples.mdn.mozilla.net/media/examples/grapefruit-slice-332-332.jpg',
}}
/>
</G>
<G pointerEvents="none">
<Line
pointerEvents="none"
x1={0}
y1={0}
x2={500}
y2={0}
strokeWidth={10}
stroke="#ccc"
/>
<Line
pointerEvents="none"
x1={500}
y1={0}
x2={500}
y2={500}
strokeWidth={10}
stroke="#ccc"
/>
</G>
</G>
</Svg>
);
}
} |
@msand Could you please deploy npm version then, and I will try to retest all cases. Thank you for you quick response! |
🎉 This issue has been resolved in version 12.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@msand Hello, I have tested latest deployed v12.0.3, it is working perfectly on iOS and Android! Thanks lot, I'll close this issue 👍 🥇 |
Bug
Scenario 1:
pointerEvents="none"
doesn't work withreact-native-svg
SVG elements.For example, when we have rectangle on top of all elements and want to disable touchable behaviour for it to get an access to inner SVG elements we can't click on any SVG element, because Rectangle still blocks clicks.
Scenario 2:
For example, we are trying to find a workaround for Scenario 1 to run touch events on elements under the top SVG Rectangle, and we just drow 4 Lines to emulate Rectangle.
Lines should not block click events, as it is not a complete shape. But 4 Lines still block clicks.
Even if we draw 2 Lines (top and right side) we can't click on SVG element on the top-right area on this SVG element. Looks like 2 Lines block click events on top-right triangle area.
I'm using
PanResponder
, not just simpleonPress
events.Both issues are available on iOS/Android.
pointerEvents="box-none" doesn't work toо and even throws an exception.
Unexpected behavior
Use this code in App.js:
Scenario 1 with simple onPress callbacks:
Scenario 1 with PanResponser callbacks:
Scenario 2: (Only bottom-left triangle area on Image is clickable)
Environment info
React native info output:
Library version: 11.0.1
Steps To Reproduce
Describe what you expected to happen:
@msand Could you please check this issue?
I know that pointerEvents issues were added and closed many times, but this is the very important feature on complex SVG panes with dynamic touch interactions with PanResponder mechanism.
We have 6 places in our project with workarounds for broken pointerEvents, but now for current case we can't do anything else. Thanks a lot.
The text was updated successfully, but these errors were encountered: