Skip to content

Commit

Permalink
Fix drag and drop on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
petterhj committed Dec 11, 2023
1 parent a919071 commit eb9d52a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file. The format
- "Lifting" objectives are now also allowed during the creation flow, not only
when edited.

### Changed

- Drag and drop ordering of measurements and key results are now triggered by
using a specific handle (the "drag icon"). This prevents accidental dragging,
especially on mobile devices.

### Breaking changes

- The API endpoint for listing KPIs (measurements) now uses cursor-based
Expand Down
15 changes: 15 additions & 0 deletions src/components/KeyResultLinkCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<span class="key-result-link-card__title pkt-txt-14">
{{ title }}
</span>
<pkt-icon v-if="draggable" class="drag-icon" name="drag" />
</div>

<div>
Expand Down Expand Up @@ -56,6 +57,10 @@ export default {
required: false,
default: null,
},
draggable: {
type: Boolean,
default: false,
},
active: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -95,6 +100,16 @@ export default {
justify-content: space-between;
}
.drag-icon {
--fg-color: var(--color-grayscale-30);
cursor: move;
::v-deep svg {
height: 0.875rem;
min-height: 0.875rem;
}
}
.item-tag {
display: flex;
justify-content: end;
Expand Down
7 changes: 6 additions & 1 deletion src/components/KpiWidgetGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
</pkt-button>
</template>
</div>
<draggable v-if="hasEditRights" v-model="orderedKpis" animation="300">
<draggable
v-if="hasEditRights"
v-model="orderedKpis"
animation="300"
handle=".drag-icon"
>
<transition-group class="kpi-widget-group__kpis">
<kpi-widget-group-link
v-for="kpi in orderedKpis"
Expand Down
2 changes: 2 additions & 0 deletions src/components/panes/ObjectivePane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
v-model="orderedKeyResults"
class="objective-pane__key-results-list"
animation="300"
handle=".drag-icon"
>
<transition-group>
<key-result-link-card
Expand All @@ -72,6 +73,7 @@
:title="keyResult.name"
:progression="keyResult.progression"
:owner="keyResult.parent?.name ? keyResult.parent : null"
:draggable="true"
:active="activeKeyResult && activeKeyResult.id === keyResult.id"
/>
</transition-group>
Expand Down
1 change: 1 addition & 0 deletions src/components/widgets/WidgetKpiCard/WidgetKpiCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export default {
.drag-icon {
--fg-color: var(--color-grayscale-30);
cursor: move;
::v-deep svg {
height: 0.875rem;
Expand Down

0 comments on commit eb9d52a

Please sign in to comment.