Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STRF-4496 - Fix product options not indexing issue #1176

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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