From a71d4b4623a958bcd3891fae489881fafeebf937 Mon Sep 17 00:00:00 2001 From: Daniel Tony Date: Tue, 5 Jan 2016 14:04:02 +0200 Subject: [PATCH 1/2] Fix RTL support when using tagging - calculate right input width Hi. Just noticed that there's a "bug" when using the tagging option within an RTL document. The width of the input wasn't calculated like it should. This pull request fixes it. --- src/uiSelectController.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/uiSelectController.js b/src/uiSelectController.js index 1afccb72e..0f848f046 100644 --- a/src/uiSelectController.js +++ b/src/uiSelectController.js @@ -391,7 +391,21 @@ uis.controller('uiSelectCtrl', if (containerWidth === 0) { return false; } - var inputWidth = containerWidth - input.offsetLeft - 10; + + // Check if document is rtl + var isRTL = angular.element('html[dir="rtl"]').length > 0, + inputWidth; + + // If document is RTL - calculate offset right + if (isRTL) { + var offsetRight = containerWidth - (input.offsetLeft + ctrl.searchInput.outerWidth()); + inputWidth = containerWidth - offsetRight - 10; + } + + else { + inputWidth = containerWidth - input.offsetLeft - 10; + } + if (inputWidth < 50) inputWidth = containerWidth; ctrl.searchInput.css('width', inputWidth+'px'); return true; From 980b76638839340cba95be09dd7e767f9d0adb75 Mon Sep 17 00:00:00 2001 From: Daniel Tony Date: Tue, 5 Jan 2016 15:04:17 +0200 Subject: [PATCH 2/2] Fix options navigating on RTL documents --- src/uiSelectMultipleDirective.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uiSelectMultipleDirective.js b/src/uiSelectMultipleDirective.js index 261640105..be8b7e1f3 100644 --- a/src/uiSelectMultipleDirective.js +++ b/src/uiSelectMultipleDirective.js @@ -194,7 +194,8 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec } // Handles selected options in "multiple" mode function _handleMatchSelection(key){ - var caretPosition = _getCaretPosition($select.searchInput[0]), + var isRTL = angular.element('html[dir="rtl"]').length > 0, + caretPosition = _getCaretPosition($select.searchInput[0]), length = $select.selected.length, // none = -1, first = 0, @@ -204,19 +205,19 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec prev = $selectMultiple.activeMatchIndex-1, newIndex = curr; - if(caretPosition > 0 || ($select.search.length && key == KEY.RIGHT)) return false; + if(caretPosition > 0 || ($select.search.length && key == (isRTL ? KEY.LEFT : KEY.RIGHT))) return false; $select.close(); function getNewActiveMatchIndex(){ switch(key){ - case KEY.LEFT: + case (isRTL ? KEY.RIGHT : KEY.LEFT): // Select previous/first item if(~$selectMultiple.activeMatchIndex) return prev; // Select last item else return last; break; - case KEY.RIGHT: + case (isRTL ? KEY.LEFT : KEY.RIGHT): // Open drop-down if(!~$selectMultiple.activeMatchIndex || curr === last){ $select.activate();