Skip to content
Open
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
12 changes: 6 additions & 6 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ <h3 id="scrumHelperHeading" class="text-3xl font-semibold cursor-pointer">Scrum
<div>
<label for="startingDate" class="flex items-center font-medium text-xs"
data-i18n="startDateLabel">From:</label>
<input type="date" id="startingDate"
class="border-2 border-gray-200 bg-gray-200 rounded-xl p-1"
style="width: 96px;">
<input type="date" id="startingDate" readonly
class="border-2 border-gray-200 bg-gray-200 rounded-xl p-1"
style="width: 96px; cursor: pointer;">
</div>
<div>
<label for="endingDate" class="flex items-center font-medium text-xs"
data-i18n="endDateLabel">To:</label>
<input type="date" id="endingDate"
class="border-2 border-gray-200 bg-gray-200 rounded-xl p-1"
style="width: 96px;">
<input type="date" id="endingDate" readonly
class="border-2 border-gray-200 bg-gray-200 rounded-xl p-1"
style="width: 96px; cursor: pointer;">
</div>
</div>
<div class="flex items-center gap-1">
Expand Down
46 changes: 33 additions & 13 deletions src/scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ function setupButtonTooltips() {
}

function getToday() {
const today = new Date();
return today.toISOString().split('T')[0];
const now = new Date();
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
}

function getYesterday() {
const today = new Date();
const yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
return yesterday.toISOString().split('T')[0];
return `${yesterday.getFullYear()}-${String(yesterday.getMonth() + 1).padStart(2, '0')}-${String(yesterday.getDate()).padStart(2, '0')}`;
}

function applyI18n() {
Expand Down Expand Up @@ -1057,18 +1057,38 @@ document.addEventListener('DOMContentLoaded', () => {
yesterdayRadio.addEventListener('change', () => {
browser.storage.local.set({ yesterdayContribution: yesterdayRadio.checked });
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Combining readonly with showPicker can make the field unusable where showPicker is unsupported.

Because the inputs are readonly and only open via showPicker, environments without HTMLInputElement.prototype.showPicker will leave them non-interactive, so users can’t set dates. Consider conditionally removing readonly when showPicker is unavailable or providing an alternate date input UI in that case.

startingDateInput.addEventListener('input', () => {
window.scrumDateRangeUtils.normalizeSyncAndPersistDateRange(
startingDateInput,
endingDateInput,
);

startingDateInput.addEventListener('change', () => {
window.scrumDateRangeUtils.normalizeSyncAndPersistDateRange(
startingDateInput,
endingDateInput
Comment on lines +1061 to +1064
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider also handling keyboard-based interactions for opening the date picker.

At the moment the picker only opens on click. For keyboard users—especially with a readonly input—this may not reliably trigger, depending on the browser. To make this more robust and accessible, also handle keydown (e.g., Enter/Space) on the focused input or use focus to trigger showPicker where appropriate.

Suggested implementation:

		startingDateInput.addEventListener('change', () => {
			window.scrumDateRangeUtils.normalizeSyncAndPersistDateRange(
				startingDateInput,
				endingDateInput,
			);
		});

		// Improve keyboard accessibility for the date picker on the starting date input
		startingDateInput.addEventListener('keydown', (event) => {
			if (event.key === 'Enter' || event.key === ' ') {
				// Some browsers expose showPicker on input[type="date"]
				if (typeof startingDateInput.showPicker === 'function') {
					event.preventDefault();
					startingDateInput.showPicker();
				}
			}
		});
  1. If the ending date input also opens a date picker via click elsewhere in this file, consider adding a similar keydown handler for endingDateInput to keep behavior consistent.
  2. If there's already a shared function that handles opening the picker on click (e.g. openDatePicker(input)), you may want to reuse it in the keydown handler instead of calling showPicker directly, to keep all open-picker logic in one place.

);
});
endingDateInput.addEventListener('input', () => {
window.scrumDateRangeUtils.normalizeSyncAndPersistDateRange(
startingDateInput,
endingDateInput,
);

endingDateInput.addEventListener('change', () => {
window.scrumDateRangeUtils.normalizeSyncAndPersistDateRange(
startingDateInput,
endingDateInput
);
});


startingDateInput.addEventListener('click', () => {
if (typeof startingDateInput.showPicker === 'function') {
startingDateInput.showPicker();
}
});

endingDateInput.addEventListener('click', () => {
if (typeof endingDateInput.showPicker === 'function') {
endingDateInput.showPicker();
}
});

const now = new Date();
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
startingDateInput.max = today;
endingDateInput.max = today;

// Save username to storage on input and update button state
platformUsername.addEventListener('input', () => {
Expand Down
Loading