Skip to content

Commit

Permalink
Fix shift click on X of tooltip not working to disable the tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Jul 24, 2024
1 parent 9b9e8b6 commit 9630e11
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
6 changes: 6 additions & 0 deletions src/content-scripts/content_script/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,9 @@ export async function main(
pageActivityIndicatorBG,
localStorageAPI: browser.storage.local,
syncSettingsBG: syncSettingsBG,
toggleTooltipState: async (state: boolean) => {
tooltipUtils.setTooltipState(state)
},
})
components.tooltip?.resolve()
},
Expand Down Expand Up @@ -1315,6 +1318,9 @@ export async function main(
updateRibbon: async () => inPageUI.updateRibbon(),
showContentTooltip: async () => inPageUI.showTooltip(),
insertTooltip: async () => inPageUI.showTooltip(),
toggleTooltipState: async (state: boolean) => {
this.dependencies.tooltip.setState(state)
},
removeTooltip: async () => inPageUI.removeTooltip(),
insertOrRemoveTooltip: async () => inPageUI.toggleTooltip(),
goToHighlight: async (annotationCacheId) => {
Expand Down
1 change: 1 addition & 0 deletions src/in-page-ui/content_script/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface InPageUIContentScriptRemoteInterface {
// Tooltip
showContentTooltip(): Promise<void>
insertTooltip(): Promise<void>
toggleTooltipState(state: boolean): Promise<void>
removeTooltip(): Promise<void>
insertOrRemoveTooltip(): Promise<void>

Expand Down
3 changes: 3 additions & 0 deletions src/in-page-ui/tooltip/content_script/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface TooltipRootProps {
mount: InPageUIRootMount
params: Omit<Props, 'onTooltipInit'>
onTooltipInit: (showTooltip: () => void) => void
toggleTooltipState: (state: boolean) => Promise<void>
analyticsBG: AnalyticsCoreInterface
annotationsBG: AnnotationInterface<'caller'>
annotationsCache: PageAnnotationsCache
Expand Down Expand Up @@ -531,6 +532,7 @@ class TooltipRoot extends React.Component<TooltipRootProps, TooltipRootState> {
this.renderHighlightColorPicker
}
showColorPicker={this.state.showColorPicker}
toggleTooltipState={props.toggleTooltipState}
/>
</ThemeProvider>
</StyleSheetManager>
Expand Down Expand Up @@ -563,6 +565,7 @@ export function setupUIContainer(
syncSettingsBG={props.syncSettingsBG}
createHighlight={params.createHighlight}
getWindow={params.getWindow}
toggleTooltipState={props.toggleTooltipState}
/>,
mount.rootElement,
)
Expand Down
4 changes: 4 additions & 0 deletions src/in-page-ui/tooltip/content_script/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ export const insertTooltip = async (params: TooltipInsertDependencies) => {
},
onTooltipHide: () => params.inPageUI.hideTooltip(),
onTooltipClose: () => params.inPageUI.removeTooltip(),
toggleTooltipState: async (state: boolean) => {
params.toggleTooltipState
},
onExternalDestroy: (destroyTooltip) => {
const handleUIStateChange: SharedInPageUIEvents['stateChanged'] = (
event,
Expand Down Expand Up @@ -199,6 +202,7 @@ export const insertTooltip = async (params: TooltipInsertDependencies) => {
syncSettingsBG: params.syncSettingsBG,
createHighlight: params.createHighlight,
getWindow: () => window,
toggleTooltipState: params.toggleTooltipState,
},
)

Expand Down
1 change: 1 addition & 0 deletions src/in-page-ui/tooltip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export interface TooltipDependencies extends AnnotationFunctions {
pageActivityIndicatorBG: RemotePageActivityIndicatorInterface
localStorageAPI: Storage.LocalStorageArea
syncSettingsBG: RemoteSyncSettingsInterface
toggleTooltipState: (state: boolean) => Promise<void>
}

0 comments on commit 9630e11

Please sign in to comment.