0

I have created a custom lookup component in lwc from here. This lookup is working fine. When I place this component in another component, with each lookup value selection the width of input is getting increased.

What can I do to fix this, so that its width does not get auto increased?

Without selection: enter image description here

With Selection: enter image description here

HTML:

<template>
    <lightning-record-edit-form object-api-name="CustomObj__c" onsuccess={handleSuccess} onsubmit={handleSubmit}>
        <lightning-layout>
            <lightning-layout-item flexibility="auto" padding="around-small">
                <lightning-input-field field-name="Name" disabled="true" ></lightning-input-field>
            </lightning-layout-item>
            <lightning-layout-item flexibility="auto" padding="around-small">
                <c-lookup
                selection={assignedToInitialSelection}
                errors={errors}
                onsearch={handleSearch}
                onselectionchange={handleSelectionChange}
                label="Contact"
                placeholder="Search Salesforce"
                data-id="selectedContact"
                is-multi-entry={isMultiEntryAssignedTo}></c-lookup>
            </lightning-layout-item>
        </lightning-layout>
        </lightning-record-edit-form>
</template>
1
  • Maybe you could assign flexibility to a var and change it from auto to fixed (or whatever) after initial load. – Caspar Harmer Mar 31 at 17:30
1

This is likely because you have set the flexibility of your layout-item's to auto.

depending on the behavior you want, you can check the documentation for setting a fixed width or adjusting it based on the device being used.

2
  • even if I give other options like no-shrink, it's width is getting changed – sfdc Mar 31 at 17:01
  • try setting fixed sizes as mentioned in the documentation – glls Mar 31 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.