Skip to content

Commit 4543e9c

Browse files
authored
Merge pull request #5771 from farooqu/macos-boolean-edit-fix
fix(edit): fix boolean edit issue on Firefox and Safari on macOS
2 parents ff4e251 + 2059db9 commit 4543e9c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/features/edit/js/gridEdit.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,20 @@
966966
});
967967
}
968968

969-
$elm.on('blur', function (evt) {
970-
$scope.stopEdit(evt);
969+
// macOS will blur the checkbox when clicked in Safari and Firefox,
970+
// to get around this, we disable the blur handler on mousedown,
971+
// and then focus the checkbox and re-enable the blur handler after $timeout
972+
$elm.on('mousedown', function(evt) {
973+
if ($elm[0].type === 'checkbox') {
974+
$elm.off('blur', $scope.stopEdit);
975+
$timeout(function() {
976+
$elm.focus();
977+
$elm.on('blur', $scope.stopEdit);
978+
});
979+
}
971980
});
981+
982+
$elm.on('blur', $scope.stopEdit);
972983
});
973984

974985

@@ -1132,9 +1143,9 @@
11321143
//set focus at start of edit
11331144
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
11341145
$timeout(function(){
1135-
$elm[0].focus();
1146+
$elm[0].focus();
11361147
});
1137-
1148+
11381149
$elm[0].style.width = ($elm[0].parentElement.offsetWidth - 1) + 'px';
11391150
$elm.on('blur', function (evt) {
11401151
$scope.stopEdit(evt);

0 commit comments

Comments
 (0)