Skip to content

Conversation

@dipikabh
Copy link
Contributor

@dipikabh dipikabh commented Jan 8, 2026

This is a follow up to #371, which was loading 2030 as the starting year in the form, picking from the first option in the HTML drop-down list.

This PR:

  • Sets the year on form load to the current year as well as after a to-do entry.
  • Updates the list of years in the drop-down to an ascending order.

Motivation

To avoid future updates to this UI every time the year changes

Additional details

The app link can be accessed at https://mdn.github.io/dom-examples/to-do-notifications/

@dipikabh dipikabh requested a review from a team as a code owner January 8, 2026 16:54
@dipikabh dipikabh requested a review from pepelsbey January 8, 2026 16:54
year.value = 2026;
day.value = "01";
month.value = "January";
year.value = new Date().getFullYear();
Copy link
Contributor Author

@dipikabh dipikabh Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this line (instead of hard-coding it to a year)

Comment on lines 91 to 103
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
<option value="2026">2026</option>
<option value="2027">2027</option>
<option value="2028">2028</option>
<option value="2029">2029</option>
<option value="2030">2030</option>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reordered this list to be in ascending order

Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you 😊

I have another idea: we can avoid changing the dates altogether, even in 2030!

This will generate a list of 13 options, starting with the current year (2026–2038)

  // Populate year options: current year and 12 years into the future
  const currentYear = new Date().getFullYear();
  for (let i = 0; i <= 12; i++) {
    const option = document.createElement("option");
    const yearValue = currentYear + i;
    option.value = yearValue;
    option.textContent = yearValue;
    year.appendChild(option);
  }

And then we set it:

  year.value = currentYear;

I would remove all the pre-filled years from HTML too and leave the <select> empty.

I wish I could’ve suggested it, but GitHub won’t allow it 🥲

image

@dipikabh
Copy link
Contributor Author

Sorry it took me a while to get back to this task.
Thanks for the review and nice suggestion! I've made the suggested updates.

I've added 2 more files to this PR:

  • to-do-notifications/README.md: Updated the description and added a link to the corresponding page in content
  • Repo README.md: An entry for this app was missing

I'll open a content PR to make sure the tutorial there reflects the same code.

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.

2 participants