From 14c4d1392efc5a193f9bd07d62336d0c63de369e Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Sun, 16 Dec 2018 23:30:23 +0800 Subject: [PATCH] Datatable dropdown usability tweaks (#3980) Adds a couple of usability tweaks to the dropdown cell type in the data table widget, to more closely mimic a native dropdown field. Pressing the up or down arrow keys when the cell is focused but with the dropdown closed will select the previous or next item automatically and set it as the cell value. This does prevent the usual table function of going to the previous or next row when focused on a dropdown cell, but I think it's a worthwhile trade-off. When the dropdown is open, the up and down arrows work the same as previously implemented. Typing out characters will initiate a search and select the first matching option automatically and set it as the cell value. For example, for the following options: Apples Oranges Bananas Typing out o and r on the keyboard will automatically select the Oranges option. Credit to @bennothommo --- .../widgets/table/assets/css/table.css | 4 +- .../widgets/table/assets/js/build-min.js | 72 ++++--- .../backend/widgets/table/assets/js/table.js | 38 ++-- .../assets/js/table.processor.dropdown.js | 175 +++++++++++++++--- .../widgets/table/assets/less/table.less | 6 +- 5 files changed, 221 insertions(+), 74 deletions(-) diff --git a/modules/backend/widgets/table/assets/css/table.css b/modules/backend/widgets/table/assets/css/table.css index c0682ee1c..ebc7b2b92 100644 --- a/modules/backend/widgets/table/assets/css/table.css +++ b/modules/backend/widgets/table/assets/css/table.css @@ -395,9 +395,7 @@ html.cssanimations .control-table td[data-column-type=dropdown] [data-view-conta cursor: pointer; outline: none; } -.table-control-dropdown-list li:hover, -.table-control-dropdown-list li:focus, -.table-control-dropdown-list li.selected { +.table-control-dropdown-list li:focus { background: #34495e; color: white; } diff --git a/modules/backend/widgets/table/assets/js/build-min.js b/modules/backend/widgets/table/assets/js/build-min.js index c952a6c34..ec262147f 100644 --- a/modules/backend/widgets/table/assets/js/build-min.js +++ b/modules/backend/widgets/table/assets/js/build-min.js @@ -266,10 +266,8 @@ return for(var i=0,len=this.options.columns.length;i