Skip to content

Commit

Permalink
Fix a bunch of bugs related to the color picker UX
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Jul 27, 2024
1 parent e398e53 commit 3a034d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
22 changes: 13 additions & 9 deletions src/annotations/components/highlightColorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ export default class HighlightColorPicker extends React.Component<
}

componentWillUnmount(): void {
if (this.state.highlightColorStateChanged) {
this.saveHighlightColorSettings()
}
// if (this.state.highlightColorStateChanged) {
// this.saveHighlightColorSettings()
// }
}

getHighlightColorSettings = async () => {
getHighlightColorSettings = async (forceUpdate?) => {
let highlightColors = this.state.highlightColorSettingState
if (!highlightColors) {
if (!highlightColors || forceUpdate) {
highlightColors = await this.syncSettings.highlightColors.get(
'highlightColors',
)
Expand Down Expand Up @@ -176,6 +176,9 @@ export default class HighlightColorPicker extends React.Component<
modifyDomHighlightColor(highlight, colorItem)
}
}
this.setState({
highlightColorSettingState: this.state.highlightColorSettingState,
})

await this.syncSettings.highlightColors.set(
'highlightColors',
Expand All @@ -195,11 +198,12 @@ export default class HighlightColorPicker extends React.Component<
onClick={(event) => {
event.stopPropagation()
}}
key={'ColorEditBox' + index}
>
<TopBarBox>
<PrimaryAction
label={'Cancel'}
onClick={(event) => {
onClick={async (event) => {
let highlights: NodeListOf<Element> = document.querySelectorAll(
'.' + DEF_HIGHLIGHT_CSS_CLASS,
)
Expand All @@ -225,11 +229,10 @@ export default class HighlightColorPicker extends React.Component<
const newShowEditColor = [
...this.state.showEditColor,
]

this.getHighlightColorSettings(true)
newShowEditColor[index] = false
this.setState({
highlightColorSettingState: [
...this.state.highlightColorSettingState,
],
showColorEditorPanel: false,
showEditColor: newShowEditColor,
})
Expand Down Expand Up @@ -465,6 +468,7 @@ export default class HighlightColorPicker extends React.Component<
}}
active={this.state.showEditColor[i]}
selected={this.state.selectedRow === i}
key={colorId}
>
<ColorPickerCircle
backgroundColor={RGBAobjectToString(
Expand Down

0 comments on commit 3a034d3

Please sign in to comment.