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

Fix problem with item name dropdown selection #4797

Closed
wants to merge 5,916 commits into from

Conversation

coalest
Copy link
Collaborator

@coalest coalest commented Nov 21, 2024

Resolves #4547

Description

This issue occurs when an ajax call to populate the item names in the dropdown options occurs while the dropdown has been opened. Selecting an option doesn't work because that option no longer exists, so nothing happens (so item selected in the field will be the first item from the list of new options).

To fix this I made two changes:

  1. Added an event listener so that whenever a item name dropdown option is selected, if the id of that item matches in the list of new options, select that option. (Note: This is enough to fix the bug)
  2. But during investigation I found that when adding a new item, two ajax calls are fired off (to /inventory.json) every time you click "Add Another Item". And an ajax call is made to fetch the inventory whenever the storage location changes. I'm assuming it's not needed to fetch the inventory so often. So I changed it to only fetch the inventory item names/quantities on storage location field change, then we store those dropdown options and reuse them whenever a new line item is added.

This will make adding new line items more responsive, and with less jank (from the reduced number of ajax calls) (ie. the item name changing from "XL Diapers" to "XL Diapers (1353)").

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested manually in Chrome on my local machine, using the reproduction steps provided here.

Testing has been tough. I see a similar issue to the one I'm having where the inputevent isn't being triggered by cuprite. In my case the select2:select event isn't being triggered for some reason.

lit-poks and others added 30 commits October 9, 2024 20:53
Add partner group to organization. Add new partner for seed
* validate the presence of business name for a vendor

add validation for business name on vendor model, skip validation in provideable when the model is a vendor to prevent duplicate errors on invalid form submission, specs for both changes

* create migration to update a vendor's business name to its contact name if business name is blank

* move product drive participant validations out of provideable and into model instead of skipping when the provideable model is vendor

* fix arg name
* Change button from 'Promote to Admin' to 'Edit User'

* Replace system spec with request spec for link for editing user

* Replace system spec with request spec for link for editing user
…n beside Add a Partner link. Add system tests to ensure the Partner cta section has 2 links. (#4710)

Co-authored-by: Athira Kadampatta <[email protected]>
# Conflicts:
#	app/controllers/distributions_controller.rb
#	spec/rails_helper.rb
* Add view password functionality to login form

* refactored the password visiblity toggle into a Stimulus controller
user docs cont v:  draft inventory section of user guide
User docs cont vi: draft exports section of user guide
Fix inventory seeding for storage location from donations
- rename service class
- update test specs
- update report name
Add feature to print unfulfilled requests as a picklists PDF
awwaiid and others added 25 commits December 15, 2024 10:43
…ils-7.2.2

 Conflicts:
	Gemfile.lock
	app/models/request.rb
build(deps): bump rails from 7.1.3.4 to 7.2.2
* Fix unexpected issued_at behavior when date field empty.

Previously before_save and before_create callbacks set the value for issued_at
created_at end of day if no datetime was provided. This prevented records being
saved with no issue date. But it caused unexpected behavior when creating or
updating a donation/purchase/distribution with an empty issued_at field,
silently changing the issued_at date to something potentially incorrect.

* Fix missing partner dropdown options of distribution update fail

* Revert partner list fix
* Fix unitialized money_rails constant error

* Fix require statement file_path and edit comment
This test expects the requests in the export to be in a particular order,
but no order is applied to the requests passed in and no order is defined
in the ExportCreateService itself, hence the flakiness.

Example failure: https://github.com/rubyforgood/human-essentials/actions/runs/12353561322/job/34472934783#step:7:1433
…#4801)

* Migration for partner agency cleanup re issue 4241.  Necessary step, but does not complete that issue.

* save! instead of save

* save! instead of save
* Fix flaky family requests system spec

* Fix flaky system partners children spec
…to 6.5.0 (#4813)

* build(deps-dev): bump factory_bot_rails from 6.4.3 to 6.4.4

Bumps [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails) from 6.4.3 to 6.4.4.
- [Release notes](https://github.com/thoughtbot/factory_bot_rails/releases)
- [Changelog](https://github.com/thoughtbot/factory_bot_rails/blob/main/NEWS.md)
- [Commits](thoughtbot/factory_bot_rails@v6.4.3...v6.4.4)

---
updated-dependencies:
- dependency-name: factory_bot_rails
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix merge conflicts with main

* Update puma to 6.5.0

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Daniel Orner <[email protected]>
Co-authored-by: Brock Wilcox <[email protected]>
Co-authored-by: Cory Streiff <[email protected]>
We were saving a new distribution (which causes a redirect to that
distribution's show page) and then immediately clicking on the distributions
index page (which redirects as well). This introduced a race condition that
was flaky when we tried to click a link that didn't exist on the page.
We were expecting the `family_zipcodes_list` to have a certain order
but no order is guaranteed in the request.
* lowered pagination threshold in dev and staging using kaminari

* Trigger Build
…4873)

* Data Fix re started reqeusts that were actually fulfilled

* Data Fix re started reqeusts that were actually fulfilled
* build(deps-dev): bump rubocop from 1.65.1 to 1.68.0

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.65.1 to 1.68.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v1.65.1...v1.68.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update rubocop

* Fix linting

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Daniel Orner <[email protected]>
Co-authored-by: Brock Wilcox <[email protected]>
Co-authored-by: Cory Streiff <[email protected]>
Co-authored-by: Cory Streiff <[email protected]>
…y-report-performance

Perf: refactor DistributionsByCountry#report using raw SQL query
@cielf cielf dismissed their stale review December 21, 2024 14:44

addressed

@coalest coalest force-pushed the 4547-item-dropdown-problem-fix branch from 0f2be75 to dc6bbe2 Compare December 21, 2024 15:44
@coalest coalest closed this by deleting the head repository Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with item dropdowns