- Home
- Forum
- Angular - EJ 2
- how to disable native unselection of cards when clicked outside of Kanban
how to disable native unselection of cards when clicked outside of Kanban
Dears,
Please advice of how we can disable native (internal) behaviour of Kanban in this scenario
1) Click on Kanban card (selected state)
2) Click outside of Kanban, or it's wrapper (from the demos - click on the navigation ribbon - most top UI element)
3) Card is de-selected - this is different than any other component from Syncfusion library that we use (~15)
Ideally the card should stay selected UNTILL unclicked manually, or by any other programmatic needs (backed up by business)
This is a huge problem for us, as we share data between components - and when we interact with Target component it's data gets lost - as selection of card is gone.
https://ej2.syncfusion.com/angular/demos/#/tailwind3/kanban/overview
Will be grateful for your support,
KJ
Attachment: Kanban_Outside_click_ce8de8db.png
private lastSelectedCardId: string | null = null; // Track the selected card's ID (use your card's unique key) private lastSelectedElement: HTMLElement | null = null; // Handle card click to track selection/deselection public onCardClick(args): void { const clickedCardId = args.data.Id; // Assume 'Id' is your unique card key; adjust as needed const clickedElement = args.element as HTMLElement; if (this.lastSelectedCardId === clickedCardId) { // Manual deselection: allow it and reset tracking this.lastSelectedCardId = null; this.lastSelectedElement = null; clickedElement.classList.remove('e-selection'); } else { // New selection: update tracking this.lastSelectedCardId = clickedCardId; this.lastSelectedElement = clickedElement; } } @HostListener('document:click', ['$event']) public onDocumentClick(event: MouseEvent): void { const target = event.target as HTMLElement; const kanbanElement = this.kanbanObj.element; if (this.lastSelectedCardId && !kanbanElement.contains(target)) { // Click outside: re-select visually after potential internal deselection setTimeout(() => { if ( this.lastSelectedElement && !this.lastSelectedElement.classList.contains('e-selection') ) { this.lastSelectedElement.classList.add('e-selection'); } }, 0); } } |
Hello,
We've decided to override the documentClick for layoutModule manually to make sure that clicking outside of Kanban does not unselect it.
Would that be possible for you to just wrap that logic with some flag, like 'clearSelectionCardOutsideOfKanban' - so it's decided by business use case - not internal magic behaviour?
Best regards,
KJ
- 3 Replies
- 2 Participants
-
KJ Karol Januszczak
- Feb 24, 2026 03:16 PM UTC
- Mar 6, 2026 07:40 AM UTC