Skip to content

Commit feddb98

Browse files
fix bookmark and spaces addition buttons in the popup
1 parent 1acce0e commit feddb98

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/popup/bookmark-button/components/BookmarkButton.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ interface StateProps {
3030
}
3131

3232
interface DispatchProps {
33-
toggleBookmark: ClickHandler<HTMLButtonElement>
33+
toggleBookmark: (element: HTMLElement) => void
3434
}
35-
3635
export type Props = OwnProps & StateProps & DispatchProps
3736

3837
class BookmarkButton extends PureComponent<Props> {
@@ -67,7 +66,11 @@ class BookmarkButton extends PureComponent<Props> {
6766

6867
return (
6968
<ButtonItem
70-
onClick={() => !isPageSaved && this.props.toggleBookmark}
69+
onClick={(event) => {
70+
if (!isPageSaved) {
71+
this.props.toggleBookmark(event.currentTarget)
72+
}
73+
}}
7174
disabled={this.props.isDisabled || isPageSaved}
7275
>
7376
<Icon
@@ -140,15 +143,11 @@ const mapDispatch: (dispatch, props: OwnProps) => DispatchProps = (
140143
dispatch,
141144
props,
142145
) => ({
143-
toggleBookmark: async (e) => {
144-
{
145-
const allowed = await pageActionAllowed(analyticsBG)
146-
147-
if (allowed) {
148-
e.preventDefault()
146+
toggleBookmark: async (element: HTMLElement) => {
147+
const allowed = await pageActionAllowed(analyticsBG)
149148

150-
await dispatch(acts.toggleBookmark())
151-
}
149+
if (allowed) {
150+
await dispatch(acts.toggleBookmark())
152151
}
153152
},
154153
})

src/popup/collections-button/components/CollectionsButton.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ interface StateProps {
2020
}
2121

2222
interface DispatchProps {
23-
toggleCollectionsPopup: ClickHandler<HTMLButtonElement>
24-
toggleAllTabsPopup: ClickHandler<HTMLButtonElement>
23+
toggleCollectionsPopup: ClickHandler<HTMLDivElement>
24+
toggleAllTabsPopup: ClickHandler<HTMLDivElement>
2525
}
2626

2727
export type Props = OwnProps & StateProps & DispatchProps
@@ -55,9 +55,11 @@ class CollectionsButton extends PureComponent<Props> {
5555
render() {
5656
return (
5757
<ButtonItem
58-
onClick={() =>
59-
!this.props.isDisabled && this.props.toggleCollectionsPopup
60-
}
58+
onClick={(event) => {
59+
if (!this.props.isDisabled) {
60+
this.props.toggleCollectionsPopup(event)
61+
}
62+
}}
6163
disabled={this.props.isDisabled}
6264
>
6365
<Icon

0 commit comments

Comments
 (0)