diff --git a/packages/component-base/src/slot-controller.d.ts b/packages/component-base/src/slot-controller.d.ts index b2f7d8dbef..97c14abc07 100644 --- a/packages/component-base/src/slot-controller.d.ts +++ b/packages/component-base/src/slot-controller.d.ts @@ -38,6 +38,7 @@ export class SlotController extends EventTarget implements ReactiveController { multiple?: boolean; observe?: boolean; useUniqueId?: boolean; + uniqueIdPrefix?: string; initializer?(host: HTMLElement, node: HTMLElement): void; }, ); diff --git a/packages/component-base/src/slot-controller.js b/packages/component-base/src/slot-controller.js index 59e9fcc0d9..1f981c60d8 100644 --- a/packages/component-base/src/slot-controller.js +++ b/packages/component-base/src/slot-controller.js @@ -19,15 +19,14 @@ export class SlotController extends EventTarget { * @return {string} * @protected */ - static generateId(host, slotName) { - const prefix = slotName || 'default'; + static generateId(host, prefix = 'default') { return `${prefix}-${host.localName}-${generateUniqueId()}`; } constructor(host, slotName, tagName, config = {}) { super(); - const { initializer, multiple, observe, useUniqueId } = config; + const { initializer, multiple, observe, useUniqueId, uniqueIdPrefix } = config; this.host = host; this.slotName = slotName; @@ -42,7 +41,7 @@ export class SlotController extends EventTarget { // Only generate the default ID if requested by the controller. if (useUniqueId) { - this.defaultId = this.constructor.generateId(host, slotName); + this.defaultId = this.constructor.generateId(host, uniqueIdPrefix || slotName); } } diff --git a/packages/date-picker/src/vaadin-date-picker.js b/packages/date-picker/src/vaadin-date-picker.js index e3bee15637..2f32224590 100644 --- a/packages/date-picker/src/vaadin-date-picker.js +++ b/packages/date-picker/src/vaadin-date-picker.js @@ -213,12 +213,21 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element super.ready(); this.addController( - new InputController(this, (input) => { - this._setInputElement(input); - this._setFocusElement(input); - this.stateTarget = input; - this.ariaTarget = input; - }), + new InputController( + this, + (input) => { + this._setInputElement(input); + this._setFocusElement(input); + this.stateTarget = input; + this.ariaTarget = input; + }, + { + // The "search" word is a trick to prevent Safari from enabling AutoFill, + // which is causing click issues: + // https://github.com/vaadin/web-components/issues/6817#issuecomment-2268229567 + uniqueIdPrefix: 'search-input', + }, + ), ); this.addController(new LabelledInputController(this.inputElement, this._labelController)); diff --git a/packages/date-picker/test/dom/__snapshots__/date-picker.test.snap.js b/packages/date-picker/test/dom/__snapshots__/date-picker.test.snap.js index 6b59512fda..459eada66a 100644 --- a/packages/date-picker/test/dom/__snapshots__/date-picker.test.snap.js +++ b/packages/date-picker/test/dom/__snapshots__/date-picker.test.snap.js @@ -4,7 +4,7 @@ export const snapshots = {}; snapshots["vaadin-date-picker host default"] = `