Skip to content

Commit 2cb5aaa

Browse files
authored
fix: Safari not triggering buttons anchors (#146)
1 parent 60080da commit 2cb5aaa

File tree

17 files changed

+85
-24
lines changed

17 files changed

+85
-24
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package Rocket.Chat.Fuselage
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.2.0-alpha.28",
2+
"version": "0.2.0-alpha.29",
33
"npmClient": "yarn",
44
"useWorkspaces": true,
55
"packages": [

packages/fuselage-hooks/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package @rocket.chat/fuselage-hooks
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816
**Note:** Version bump only for package @rocket.chat/fuselage-hooks

packages/fuselage-hooks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/fuselage-hooks",
3-
"version": "0.2.0-alpha.28",
3+
"version": "0.2.0-alpha.29",
44
"description": "React Hooks for Fuselage, Rocket.Chat's design system",
55
"homepage": "https://rocket.chat/Rocket.Chat.Fuselage",
66
"author": {

packages/fuselage-tokens/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package @rocket.chat/fuselage-tokens
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816
**Note:** Version bump only for package @rocket.chat/fuselage-tokens

packages/fuselage-tokens/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/fuselage-tokens",
3-
"version": "0.2.0-alpha.28",
3+
"version": "0.2.0-alpha.29",
44
"description": "Design tokens for Fuselage, Rocket.Chat's design system",
55
"homepage": "https://rocket.chat/Rocket.Chat.Fuselage",
66
"author": {

packages/fuselage-ui-kit/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package @rocket.chat/fuselage-ui-kit
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816
**Note:** Version bump only for package @rocket.chat/fuselage-ui-kit

packages/fuselage-ui-kit/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/fuselage-ui-kit/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/fuselage-ui-kit",
3-
"version": "0.2.0-alpha.28",
3+
"version": "0.2.0-alpha.29",
44
"description": "Package ui kit ",
55
"author": "Guilherme Gazzo <guilhermegazzo@gmail.com>",
66
"homepage": "https://github.com/RocketChat/Rocket.Chat.Fuselage#readme",
@@ -35,7 +35,7 @@
3535
"url": "https://github.com/RocketChat/Rocket.Chat.Fuselage/issues"
3636
},
3737
"dependencies": {
38-
"@rocket.chat/ui-kit": "^0.2.0-alpha.28"
38+
"@rocket.chat/ui-kit": "^0.2.0-alpha.29"
3939
},
4040
"peerDependencies": {
4141
"@rocket.chat/fuselage": "^0.2.0-alpha.23",
@@ -47,7 +47,7 @@
4747
"@babel/plugin-transform-runtime": "^7.5.0",
4848
"@babel/preset-env": "^7.4.5",
4949
"@babel/preset-react": "^7.7.4",
50-
"@rocket.chat/fuselage": "^0.2.0-alpha.28",
50+
"@rocket.chat/fuselage": "^0.2.0-alpha.29",
5151
"@storybook/addon-actions": "5.2.4",
5252
"@storybook/addon-backgrounds": "5.2.4",
5353
"@storybook/addon-centered": "5.2.4",

packages/fuselage-ui-kit/src/Overflow.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@ export const Overflow = ({ context, options, parser, ...element }) => {
2222
hide();
2323
});
2424

25+
const ref = useRef();
26+
const onClick = useCallback(() => ref.current.focus() & show(), []);
27+
2528
const handleSelection = useCallback((...args) => {
2629
fireChange(...args);
2730
reset();
2831
hide();
2932
}, []);
30-
const ref = useRef();
3133
return (
3234
<>
3335
<Button
3436
ref={ref}
3537
small
36-
ghost onClick={show}
38+
ghost
39+
onClick={onClick}
3740
onBlur={hide}
3841
onKeyUp={handleKeyUp}
3942
onKeyDown={handleKeyDown}

packages/fuselage/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package @rocket.chat/fuselage
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816

packages/fuselage/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/fuselage",
3-
"version": "0.2.0-alpha.28",
3+
"version": "0.2.0-alpha.29",
44
"author": {
55
"name": "Rocket.Chat",
66
"url": "https://rocket.chat/"
@@ -48,7 +48,7 @@
4848
"@babel/preset-env": "^7.7.6",
4949
"@babel/preset-react": "^7.7.4",
5050
"@rocket.chat/eslint-config": "^0.4.0",
51-
"@rocket.chat/fuselage-hooks": "^0.2.0-alpha.28",
51+
"@rocket.chat/fuselage-hooks": "^0.2.0-alpha.29",
5252
"@storybook/addon-actions": "5.2.8",
5353
"@storybook/addon-backgrounds": "5.2.8",
5454
"@storybook/addon-centered": "5.2.8",
@@ -120,8 +120,8 @@
120120
}
121121
},
122122
"dependencies": {
123-
"@rocket.chat/fuselage-tokens": "^0.2.0-alpha.28",
124-
"@rocket.chat/icons": "^0.2.0-alpha.28"
123+
"@rocket.chat/fuselage-tokens": "^0.2.0-alpha.29",
124+
"@rocket.chat/icons": "^0.2.0-alpha.29"
125125
},
126126
"browserslist": {
127127
"production": [

packages/fuselage/src/components/Box/Position/index.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,19 @@ export const Position = ({ anchor, width = 'stretch', style, className, children
5858
const [position, setPosition] = useState();
5959
const ref = useRef();
6060

61-
const { offsetWidth } = anchor.current || {};
61+
const resizer = useRef();
6262

63+
const { offsetWidth } = anchor.current || {};
6364
useLayoutEffect(() => {
6465
if (!ref.current || !anchor.current) {
6566
return;
6667
}
6768
const [vertical, horizontal] = placement.split(' ');
6869

69-
if (typeof ResizeObserver === 'undefined') {
70-
return;
71-
}
7270
const handlePosition = throttle(() => {
7371
const anchorPosition = offset(anchor.current);
7472
const elementPosition = offset(ref.current.parentElement);
73+
7574
setPosition({
7675
...width === 'stretch' && anchor.current && {
7776
width: offsetWidth,
@@ -87,20 +86,23 @@ export const Position = ({ anchor, width = 'stretch', style, className, children
8786
}, 30);
8887

8988
handlePosition();
90-
const resizeObserver = new ResizeObserver(handlePosition);
89+
90+
const { current } = anchor;
91+
if (typeof ResizeObserver !== 'undefined') {
92+
resizer.current = new ResizeObserver(handlePosition);
93+
resizer.current.observe(current);
94+
}
9195

9296
window.addEventListener('scroll', handlePosition);
9397
window.addEventListener('resize', handlePosition);
94-
const { current } = anchor;
9598

96-
resizeObserver.observe(current);
9799

98100
return () => {
99101
window.removeEventListener('scroll', handlePosition);
100102
window.removeEventListener('resize', handlePosition);
101-
resizeObserver.unobserve(current);
103+
resizer.current && resizer.current.unobserve(current);
102104
};
103-
}, [anchor.current, anchor.current, placement, offsetWidth]);
105+
}, [anchor.current, placement, offsetWidth]);
104106

105107
const portalContainer = useMemo(() => {
106108
const element = document.createElement('div');

packages/icons/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package @rocket.chat/icons
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816
**Note:** Version bump only for package @rocket.chat/icons

packages/icons/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/icons",
3-
"version": "0.2.0-alpha.28",
3+
"version": "0.2.0-alpha.29",
44
"author": {
55
"name": "Rocket.Chat",
66
"url": "https://rocket.chat/"

packages/ui-kit/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-alpha.29](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.28...v0.2.0-alpha.29) (2020-02-10)
7+
8+
**Note:** Version bump only for package @rocket.chat/ui-kit
9+
10+
11+
12+
13+
614
# [0.2.0-alpha.28](https://github.com/RocketChat/Rocket.Chat.Fuselage/compare/v0.2.0-alpha.27...v0.2.0-alpha.28) (2020-02-10)
715

816
**Note:** Version bump only for package @rocket.chat/ui-kit

packages/ui-kit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/ui-kit",
3-
"version": "0.2.0-alpha.28",
3+
"version": "0.2.0-alpha.29",
44
"description": "Package Fuselage ui kit ",
55
"author": "Guilherme Gazzo <guilhermegazzo@gmail.com>",
66
"homepage": "https://github.com/RocketChat/Rocket.Chat.Fuselage#readme",

0 commit comments

Comments
 (0)