Skip to content

Commit

Permalink
fix(UX): Avoid outside click while selecting text
Browse files Browse the repository at this point in the history
closes: #229
  • Loading branch information
surajshetty3416 committed Oct 25, 2024
1 parent 24ed39b commit d1b80e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frontend/src/components/BuilderBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ const triggerContextMenu = (e: MouseEvent) => {
const handleClick = (e: MouseEvent) => {
if (isEditable.value) return;
if (store.preventClick) {
e.stopPropagation();
e.preventDefault();
store.preventClick = false;
return;
}
selectBlock(e);
e.stopPropagation();
e.preventDefault();
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/TextBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@
<editor-content
@click="handleClick"
:editor="editor"
@mousedown="selectionTriggered = true"
@mousemove="
() => {
if (selectionTriggered) {
store.preventClick = true;
}
}
"
@mouseup="selectionTriggered = false"
v-if="editor && showEditor"
class="relative z-50"
:style="block.getRawStyles()"
Expand Down Expand Up @@ -144,6 +153,7 @@ const linkInput = ref(null) as Ref<typeof TextInput | null>;
const component = ref(null) as Ref<HTMLElement | null>;
const overlayElement = document.querySelector("#overlay") as HTMLElement;
let editor: Ref<Editor | null> = ref(null);
let selectionTriggered = false as boolean;
const props = defineProps({
block: {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const useStore = defineStore("store", {
autoSave: true,
pageBlocks: <Block[]>[],
propertyFilter: <string | null>null,
preventClick: false,
builderLayout: {
rightPanelWidth: 275,
leftPanelWidth: 250,
Expand Down

0 comments on commit d1b80e5

Please sign in to comment.