Better error message if Datepicker calendar is clicked after input is removed from DOM?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
It can happen that after a non-inline Datepicker is opened, the <input> which the datepicker is "attached to" is removed from the DOM. When the user then clicks on the Datepicker calendar, an exception will be thrown with the message: "Missing instance data for this datepicker".
This is the relevant bit of code:
/* Adjust one of the date sub-fields. */
_adjustDate: function( id, offset, period ) {
var target = $( id ),
inst = this._getInst( target[ 0 ] );
Note that after retrieving target with $( id ), it is used right away without checking whether target.length > 0 or not. I would like to suggest it would be a good idea to make that check. If target is indeed empty, then an exception could be thrown with a more informative message.
(A web search reveals a lot of questions about the Missing instance data message; apparently it is challenging for a lot of users to understand what this message indicates.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the _adjustDate entry point shown in the issue and reproduce the non-inline Datepicker case after its attached input is removed from the DOM. Confirm the empty target is handled without the current "Missing instance data for this datepicker" exception, and that the resulting error is more informative.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100