File tree Expand file tree Collapse file tree 5 files changed +28
-3
lines changed
Expand file tree Collapse file tree 5 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 11import { GlobalContext } from "../context" ;
22import { LeftBar } from "../graphics/left_bar" ;
33import { layerToName } from "../types/layer" ;
4- import { deselectElement , saveToLocalStorage } from "../types/viewportManager" ;
4+ import {
5+ deselectElement ,
6+ isSelectedElementVisible ,
7+ saveToLocalStorage ,
8+ } from "../types/viewportManager" ;
59import {
610 Dropdown ,
711 DropdownOption ,
@@ -82,10 +86,12 @@ export class LayerHandler {
8286 this . ctx . changeLayer ( selectedLayer ) ;
8387 saveToLocalStorage ( this . ctx ) ;
8488 this . leftBar . setButtonsByLayer ( selectedLayer ) ;
85- deselectElement ( ) ;
89+ if ( ! isSelectedElementVisible ( ) ) {
90+ deselectElement ( ) ;
91+ }
8692
8793 if ( showAlert ) {
88- showSuccess ( ALERT_MESSAGES . LAYER_CHANGED , 7000 ) ;
94+ showSuccess ( ALERT_MESSAGES . LAYER_CHANGED , 5000 ) ;
8995 }
9096 }
9197}
Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ export class Edge extends Graphics {
156156 this . visible = device1CanReachVisibleDevice && device2CanReachVisibleDevice ;
157157 }
158158
159+ isVisible ( ) : boolean {
160+ return this . visible ;
161+ }
162+
159163 /**
160164 * Updates the position of an edge connecting two devices, taking into account their visibility
161165 * and dimensions. If a device is visible, the edge will leave a space around the device's center
Original file line number Diff line number Diff line change @@ -133,6 +133,10 @@ export class Packet extends Graphics {
133133 return rawPacket . getDetails ( layer ) ;
134134 }
135135
136+ isVisible ( ) : boolean {
137+ return this . visible ;
138+ }
139+
136140 getPacketLocation ( ) : PacketLocation {
137141 return {
138142 startId : this . currStart ,
Original file line number Diff line number Diff line change @@ -205,6 +205,10 @@ export abstract class ViewDevice extends Container {
205205 this . visible = layerIncluded ( this . getLayer ( ) , this . viewgraph . getLayer ( ) ) ;
206206 }
207207
208+ isVisible ( ) : boolean {
209+ return this . visible ;
210+ }
211+
208212 // Function to add the ID label to the device
209213 addDeviceIdLabel ( ) {
210214 const textStyle = new TextStyle ( {
Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ export function deselectElement() {
4848 }
4949}
5050
51+ export function isSelectedElementVisible ( ) : boolean {
52+ if ( selectedElement ) {
53+ return selectedElement . isVisible ( ) ;
54+ }
55+ return false ;
56+ }
57+
5158export function refreshElement ( ) {
5259 if ( selectedElement ) {
5360 // Deselect the current element and then reselect it to refresh
You can’t perform that action at this time.
0 commit comments