Extension: fix duplicate checkin banner and silently-unsaved default tablet
- Scope the new bookings_checkin banner to that page's own tablist only — bookings_view has a ui-tabs-nav tablist too, so it was duplicating alongside the existing arrival-reminder banner there - options.js: persist whatever the default-tablet <select> ends up showing, not just on manual change — a <select> auto-selects its first <option> without firing 'change', so a single-tablet setup (or anyone happy with the first option) never actually got a default saved despite the dropdown looking selected, which sent every injected button to the manual picker Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
9f3129b8b5
commit
db6ffb7aa4
2 changed files with 23 additions and 3 deletions
|
|
@ -358,6 +358,13 @@ function buildTabletBanner(bookingId) {
|
|||
}
|
||||
|
||||
function processCheckinPageBanner() {
|
||||
// bookings_view has its own `ui-tabs-nav` tablist too (Mandatory
|
||||
// Information / Optional Booking Details / Newbook Drive) — without this
|
||||
// guard this banner duplicated there alongside processCheckinBanner's
|
||||
// augmented reminder banner (confirmed 2026-10-01 from a live screenshot).
|
||||
// This one is purely for the dedicated bookings_checkin/<id> page.
|
||||
if (!/^\/bookings_checkin\//.test(location.pathname)) return;
|
||||
|
||||
const tablist = document.querySelector('ul[role="tablist"].ui-tabs-nav');
|
||||
if (!tablist || tablist.hasAttribute(PROCESSED_ATTR)) return;
|
||||
const bookingId = extractBookingIdFromLocation();
|
||||
|
|
|
|||
|
|
@ -40,8 +40,19 @@ async function refreshDeviceList(preselectId) {
|
|||
defaultDeviceSelect.innerHTML = devices.map(d =>
|
||||
`<option value="${d.device_id}">${escapeHtml(d.name)}</option>`
|
||||
).join('');
|
||||
if (preselectId) defaultDeviceSelect.value = preselectId;
|
||||
if (preselectId && devices.some(d => d.device_id === preselectId)) {
|
||||
defaultDeviceSelect.value = preselectId;
|
||||
}
|
||||
defaultSection.style.display = '';
|
||||
// A <select> always shows *something* selected — the browser defaults to
|
||||
// the first <option> with no explicit selection, with no 'change' event
|
||||
// firing for that. Without this, a machine with only one tablet (or
|
||||
// whoever's happy with the first one) never actually got a default
|
||||
// saved, despite the dropdown visibly showing one selected — the
|
||||
// injected buttons would then always fall back to the manual picker
|
||||
// (confirmed live 2026-10-01). Persisting whatever ends up selected here
|
||||
// keeps storage and the visible dropdown state from ever drifting apart.
|
||||
chrome.storage.local.set({ defaultDeviceId: defaultDeviceSelect.value });
|
||||
} catch {
|
||||
// Not configured/reachable yet — leave the section hidden rather than
|
||||
// showing an empty/broken picker; Test Connection surfaces the real error.
|
||||
|
|
@ -83,7 +94,8 @@ async function save() {
|
|||
await chrome.storage.local.set({ baseUrl, apiKey });
|
||||
statusEl.textContent = 'Saved.';
|
||||
statusEl.style.color = '#16a34a';
|
||||
refreshDeviceList();
|
||||
const { defaultDeviceId } = await chrome.storage.local.get('defaultDeviceId');
|
||||
refreshDeviceList(defaultDeviceId);
|
||||
}
|
||||
|
||||
async function test() {
|
||||
|
|
@ -93,7 +105,8 @@ async function test() {
|
|||
const devices = await fetchDevices();
|
||||
statusEl.textContent = `Connected — found ${devices.length} tablet(s).`;
|
||||
statusEl.style.color = '#16a34a';
|
||||
refreshDeviceList();
|
||||
const { defaultDeviceId } = await chrome.storage.local.get('defaultDeviceId');
|
||||
refreshDeviceList(defaultDeviceId);
|
||||
} catch (err) {
|
||||
statusEl.textContent = `Failed: ${err.message}`;
|
||||
statusEl.style.color = '#dc2626';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue