Skip to content

Commit

Permalink
STRF-4496 - Fix product options unhiding indexing issue (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjschock authored Mar 5, 2018
1 parent 421a542 commit 746f539
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Fix product options unhiding indexing issue. [#1176](https://github.com/bigcommerce/cornerstone/pull/1176)

## 1.13.2 (2018-02-28)

Expand Down
8 changes: 5 additions & 3 deletions assets/js/theme/common/select-option-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ function toggleOption(show) {
// move the option to the correct select element if required
if (currentSelectElement.is(':disabled') && show) {
const previousIndex = this.data('index');
if (previousIndex > 0) {
this.insertAfter(selectElement.find(`option:eq(${previousIndex - 1})`));
const $elementNowAtPreviousIndex = selectElement.find(`option:eq(${previousIndex})`);

if ($elementNowAtPreviousIndex.length) {
this.insertBefore($elementNowAtPreviousIndex);
} else {
$(this).prependTo(selectElement);
$(this).appendTo(selectElement);
}
} else if (!currentSelectElement.is(':disabled') && !show) {
this.data('index', currentSelectElement.find('option').index(this));
Expand Down

0 comments on commit 746f539

Please sign in to comment.