Skip to content

Commit

Permalink
gui: Replace JS select-on-click with CSS user-select (fixes #3868) (#…
Browse files Browse the repository at this point in the history
…8544)

Currently, a custom JS script is used to select the whole device ID on
click. However, the current script isn't compatible with all browsers
(and in IE in particular), making it impossible to select the ID in them
at all. Additionally, the same functionality is already available in CSS
with no such drawbacks, as the whole selection process is handled by the
Web browser natively, which is lightweight and does not require custom
code.

Thus, remove the currently used JS script completely, replacing it with
a new CSS class that can be added to an element when required. If the
browser does not support the CSS, the user can still select the element
manually, which makes it safer than the current behaviour that can block
the user from being able to select the element at all.

Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
  • Loading branch information
tomasz1986 committed Sep 20, 2022
1 parent 3f2742a commit 5baf5fe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
4 changes: 4 additions & 0 deletions gui/default/assets/css/overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -516,3 +516,7 @@ html[lang="ja"] i,
html[lang|="ko"] i {
font-style: normal;
}

.select-on-click {
user-select: all;
}
1 change: 0 additions & 1 deletion gui/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,6 @@ <h4 class="panel-title">
<script type="text/javascript" src="syncthing/core/notificationDirective.js"></script>
<script type="text/javascript" src="syncthing/core/pathIsSubDirDirective.js"></script>
<script type="text/javascript" src="syncthing/core/popoverDirective.js"></script>
<script type="text/javascript" src="syncthing/core/selectOnClickDirective.js"></script>
<script type="text/javascript" src="syncthing/core/syncthingController.js"></script>
<script type="text/javascript" src="syncthing/core/tooltipDirective.js"></script>
<script type="text/javascript" src="syncthing/core/uncamelFilter.js"></script>
Expand Down
14 changes: 0 additions & 14 deletions gui/default/syncthing/core/selectOnClickDirective.js

This file was deleted.

2 changes: 1 addition & 1 deletion gui/default/syncthing/device/idqrModalView.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<modal id="idqr" status="info" icon="fas fa-qrcode" heading="{{'Device Identification' | translate}} - {{deviceName(currentDevice)}}" large="yes" closeable="yes">
<div class="modal-body">
<div class="well well-sm text-monospace text-center" select-on-click>{{currentDevice.deviceID}}</div>
<div class="well well-sm text-monospace text-center select-on-click">{{currentDevice.deviceID}}</div>
<img ng-if="currentDevice.deviceID" class="center-block img-thumbnail" ng-src="qr/?text={{currentDevice.deviceID}}" alt="qr code" />

This comment has been minimized.

Copy link
@tomasz1986

tomasz1986 Aug 31, 2023

Author Contributor

This change was mistakenly overwritten by 5e384c9. Strange that no-one has noticed so far 😉. I'm very sorry and I'm going to push a fix soon!

</div>
<div class="modal-footer">
Expand Down

0 comments on commit 5baf5fe

Please sign in to comment.