Skip to content

Commit

Permalink
remove all implementations of react-onclickoutside and improve on on …
Browse files Browse the repository at this point in the history
…click-away-wrapper implementation
  • Loading branch information
blackforestboi committed Dec 3, 2022
1 parent ec97f41 commit 9436380
Show file tree
Hide file tree
Showing 28 changed files with 201 additions and 159 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
"react-firebaseui": "^4.0.0",
"react-helmet": "^5.2.1",
"react-markdown": "^5.0.0",
"react-onclickoutside": "^6.7.1",
"react-popper": "^2.3.0",
"react-redux": "^5.0.7",
"react-rnd": "^10.3.5",
Expand Down
3 changes: 1 addition & 2 deletions src/annotations/components/AnnotationCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react'
import { createRef } from 'react'

import styled from 'styled-components'
import onClickOutside from 'react-onclickoutside'

import { getKeyName } from '@worldbrain/memex-common/lib/utils/os-specific-key-names'
import MemexEditor, {
Expand Down Expand Up @@ -356,7 +355,7 @@ export class AnnotationCreate extends React.Component<Props, State>
}
}

export default onClickOutside(AnnotationCreate)
export default AnnotationCreate

const SaveCancelArea = styled.div`
display: flex;
Expand Down
1 change: 1 addition & 0 deletions src/annotations/components/AnnotationEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ export default class AnnotationEditable extends React.Component<Props> {
<PopoutBox
targetElementRef={this.tutorialButtonRef.current}
placement={'bottom'}
closeComponent={() => this.toggleShowTutorial()}
>
<QuickTutorial
markdownHelpOnTop={true}
Expand Down
3 changes: 1 addition & 2 deletions src/custom-lists/ui/CollectionPicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import onClickOutside from 'react-onclickoutside'
import styled, { ThemeProvider } from 'styled-components'

import { StatefulUIElement } from 'src/util/ui-logic'
Expand Down Expand Up @@ -534,4 +533,4 @@ const SpaceContextMenuBtn = styled.div`
align-items: center;
`

export default onClickOutside(SpacePicker)
export default SpacePicker
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import onClickOutside from 'react-onclickoutside'
import isEqual from 'lodash/isEqual'
import styled, { ThemeProvider } from 'styled-components'

Expand All @@ -15,7 +14,6 @@ import EntryResultsList from 'src/common-ui/GenericPicker/components/EntryResult
import EntryRow from 'src/common-ui/GenericPicker/components/EntryRow' // ActOnAllTabsButton, // IconStyleWrapper,
import { KeyEvent, DisplayEntry } from 'src/common-ui/GenericPicker/types'
import * as Colors from 'src/common-ui/components/design-library/colors'
import { EntrySelectedList } from 'src/common-ui/GenericPicker/components/EntrySelectedList'
import * as icons from 'src/common-ui/components/design-library/icons'
import Icon from '@worldbrain/memex-common/lib/common-ui/components/icon'

Expand Down Expand Up @@ -252,4 +250,4 @@ const DomainResultItem = styled.div`
}
`

export default onClickOutside(DomainPicker)
export default DomainPicker
7 changes: 1 addition & 6 deletions src/dashboard-refactor/header/filters-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ export default class FiltersBar extends PureComponent<FiltersBarProps> {
offsetX={10}
closeComponent={this.props.toggleDatesFilter}
>
<DatePicker
{...this.props.datePickerProps}
outsideClickIgnoreClass="date-picker-button"
/>
<DatePicker {...this.props.datePickerProps} />
</PopoutBox>
)
}
Expand All @@ -192,7 +189,6 @@ export default class FiltersBar extends PureComponent<FiltersBarProps> {
{...this.props.spacePickerProps}
searchInputPlaceholder="Add Space filters"
removeTooltipText="Remove Space filter"
outsideClickIgnoreClass="space-picker-button"
filterMode
/>
</PopoutBox>
Expand All @@ -215,7 +211,6 @@ export default class FiltersBar extends PureComponent<FiltersBarProps> {
{...this.props.domainPickerProps}
searchInputPlaceholder="Add domain filters"
removeToolTipText="Remove filter"
outsideClickIgnoreClass="domain-picker-button"
/>
</PopoutBox>
)
Expand Down
6 changes: 4 additions & 2 deletions src/dashboard-refactor/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function renderSyncStatusMenu(
targetElementRef={syncStatusButtonRef.current}
offsetX={15}
offsetY={5}
closeComponent={syncStatusMenuProps.onToggleDisplayState}
closeComponent={() => syncStatusMenuProps.onToggleDisplayState()}
placement={'bottom-end'}
>
<SyncStatusMenu
Expand Down Expand Up @@ -148,7 +148,9 @@ export default class Header extends PureComponent<Props> {
</SearchSection>
<RightHeader>
<PrimaryAction
onClick={syncStatusMenuProps.onToggleDisplayState}
onClick={() =>
syncStatusMenuProps.onToggleDisplayState()
}
label={'Sync Status'}
size={'medium'}
icon={getSyncStatusIcon(syncStatusIconState)}
Expand Down
5 changes: 2 additions & 3 deletions src/dashboard-refactor/header/sync-status-menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { PureComponent } from 'react'
import onClickOutside from 'react-onclickoutside'
import styled, { css } from 'styled-components'
import moment from 'moment'

Expand Down Expand Up @@ -62,7 +61,7 @@ export interface SyncStatusMenuProps extends RootState {
onLoginClick: React.MouseEventHandler
onClickOutside: React.MouseEventHandler
syncStatusIconState?: any
onToggleDisplayState: React.MouseEventHandler
onToggleDisplayState?: () => void
}

class SyncStatusMenu extends PureComponent<SyncStatusMenuProps> {
Expand Down Expand Up @@ -242,7 +241,7 @@ class SyncStatusMenu extends PureComponent<SyncStatusMenuProps> {
}
}

export default onClickOutside(SyncStatusMenu)
export default SyncStatusMenu

const LoadingBox = styled.div`
height: 100px;
Expand Down
16 changes: 8 additions & 8 deletions src/dashboard-refactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,9 @@ export class DashboardContainer extends StatefulUIElement<
isShown: false,
}),
onToggleDisplayState: () => {
console.log('works')
console.log('toggletriggered')
this.processEvent('setSyncStatusMenuDisplayState', {
isShown: !syncMenu.isDisplayed,
isShown: syncMenu.isDisplayed,
})
},
}}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ export class DashboardContainer extends StatefulUIElement<
<DeleteConfirmModal
isShown
message="Delete this Space?"
submessage="This does not delete the pages in it"
submessage="This does NOT delete the pages in it"
onClose={() => this.processEvent('cancelListDelete', null)}
deleteDocs={() =>
this.processEvent('confirmListDelete', null)
Expand Down Expand Up @@ -1259,11 +1259,11 @@ export class DashboardContainer extends StatefulUIElement<
isShown: false,
})
}
onToggleDisplayState={() =>
this.processEvent('setSyncStatusMenuDisplayState', {
isShown: !this.state.syncMenu.isDisplayed,
})
}
// onToggleDisplayState={() =>
// this.processEvent('setSyncStatusMenuDisplayState', {
// isShown: !this.state.syncMenu.isDisplayed,
// })
// }
/>
</RightHeader>
</HeaderBar>
Expand Down
15 changes: 13 additions & 2 deletions src/dashboard-refactor/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,18 @@ export class DashboardLogic extends UILogic<State, Events> {
})
}

setPageHover: EventHandler<'setPageHover'> = ({ event }) => {
setPageHover: EventHandler<'setPageHover'> = ({ event, previousState }) => {
if (
previousState.searchResults.results[event.day].pages.byId[
event.pageId
].isCopyPasterShown ||
previousState.searchResults.results[event.day].pages.byId[
event.pageId
].listPickerShowStatus !== 'hide'
) {
return
}

this.emitMutation({
searchResults: {
results: {
Expand Down Expand Up @@ -3178,7 +3189,7 @@ export class DashboardLogic extends UILogic<State, Events> {
'setSyncStatusMenuDisplayState'
> = async ({ event }) => {
this.emitMutation({
syncMenu: { isDisplayed: { $set: event.isShown } },
syncMenu: { isDisplayed: { $set: !event.isShown } },
})
}

Expand Down
Loading

0 comments on commit 9436380

Please sign in to comment.