-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround Android issue where click events are fired on the wrong ta…
…rget (#7026) Co-authored-by: Daniel Lu <[email protected]>
- Loading branch information
1 parent
dcbb9dc
commit c904e06
Showing
4 changed files
with
251 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/@react-aria/interactions/stories/usePress-stories.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
.outer-div { | ||
background-color: #333; | ||
width: 320px; | ||
height: 320px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
align-items: center; | ||
margin-bottom: 1000px; | ||
} | ||
|
||
.open-btn { | ||
background-color: blue; | ||
font-size: 32px; | ||
padding: 10px; | ||
} | ||
|
||
.visit-link { | ||
color: #9999ff; | ||
font-size: 16px; | ||
} | ||
|
||
.fake-modal { | ||
background-color: rgba(224, 64, 0, 0.5); | ||
position: absolute; | ||
width: 320px; | ||
height: 320px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: space-around; | ||
} | ||
|
||
.side-by-side { | ||
color: white; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
|
||
.my-btn { | ||
background-color: rgb(0, 128, 0); | ||
cursor: pointer; | ||
padding: 5px; | ||
} | ||
|
||
.fake-modal h1 { | ||
color: white; | ||
font-size: 60px; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.fake-modal .close-btn { | ||
background-color: red; | ||
font-size: 16px; | ||
padding: 10px; | ||
} | ||
|
||
.OnPress { | ||
cursor: pointer; | ||
color: #ffffff; | ||
} |
86 changes: 86 additions & 0 deletions
86
packages/@react-aria/interactions/stories/usePress.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import styles from './usePress-stories.css'; | ||
import {usePress} from '@react-aria/interactions'; | ||
|
||
export default { | ||
title: 'usePress' | ||
}; | ||
|
||
export function TouchIssue() { | ||
const [opened, setOpened] = React.useState(false); | ||
const handleOpen = React.useCallback(() => { | ||
console.log('opening'); | ||
setOpened(true); | ||
}, []); | ||
const handleClose = React.useCallback(() => { | ||
console.log('closing'); | ||
setOpened(false); | ||
}, []); | ||
const handleOnClick = React.useCallback(() => { | ||
alert('clicked it'); | ||
}, []); | ||
|
||
return ( | ||
<div className={styles['outer-div']}> | ||
<OnPress onPress={handleOpen} className={styles['open-btn']}> | ||
Open | ||
</OnPress> | ||
<div className={styles['side-by-side']}> | ||
<div>Some text</div> | ||
<a href="https://www.google.com" className={styles['visit-link']}> | ||
Another Link | ||
</a> | ||
<button className={styles['my-btn']} onClick={handleOnClick}> | ||
On Click | ||
</button> | ||
</div> | ||
|
||
{opened && ( | ||
<div className={styles['fake-modal']}> | ||
<h1>Header</h1> | ||
<div className={styles['side-by-side']}> | ||
<OnPress onPress={handleClose} className={styles['close-btn']}> | ||
Close 1 | ||
</OnPress> | ||
<OnPress onPress={handleClose} className={styles['close-btn']}> | ||
Close 2 | ||
</OnPress> | ||
<OnPress onPress={handleClose} className={styles['close-btn']}> | ||
Close 3 | ||
</OnPress> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
function OnPress(props) { | ||
const {className, onPress, children} = props; | ||
|
||
const {pressProps} = usePress({ | ||
onPress | ||
}); | ||
|
||
return ( | ||
<div | ||
{...pressProps} | ||
role="button" | ||
tabIndex={0} | ||
className={`OnPress ${className || ''}`}> | ||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c904e06
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verdaccio builds:
CRA Test App
NextJS Test App
RAC Tailwind Example
RAC Spectrum + Tailwind Example
CRA Test App Size
NextJS App Size
Publish stats
Size diff since last release
Docs
Storybook
S2 Storybook