Unble to focus autocomplete programaticly
Hi Team,
I am facing issue in setting focus for autocomplete component.
- added method on click to open bootstrap-vue modal
- In below method, added infocus for the autocomplete with ref
- We can see content of modal(pop-up) below
- I am getting below error
<a
id="add-panel"
class="add-item-panel"
@click="showAddBarEvnt"
v-if="formMode === 'add' || (salesOrderDetail && salesOrderDetail.DocumentStatus === 0)"
>
<i class="fas fa-plus-circle"></i>
</a>
showAddBarEvnt() {
// check outlet is selected
if (this.selectedOutlet) {
this.showAddBar = true
this.itemAddObj = { ...this.soLineItem }
this.$refs.sideBarSearch.focusIn()
} else {
this.$bvToast.toast('Please select Outlet before adding item!', {
title: `Error`,
variant: 'danger',
solid: true,
autoHideDelay: 3000
})
}
},
<div class="modal-content-add">
<div class="row pb-4">
<div class="col">
<div class="autocomplete">
<ejs-autocomplete
:dataSource="itemCodeOptions"
:placeholder="'search product'"
:filtering="getProducts"
:value="itemAddObj.ItemCode"
@change="changeSelectedProduct"
ref="sideBarSearch"
></ejs-autocomplete>
</div>
</div>
</div>
</div>
SIGN IN To post a reply.
3 Replies
SN
Sevvandhi Nagulan
Syncfusion Team
August 31, 2021 03:37 PM UTC
Hi Sandeep,
Greetings from Syncfusion support.
We checked your query. In the code, the component instance accessed incorrectly. Please refer the following code.
|
this.$refs.sideBarSearch.ej2Instances.focusIn()
|
Kindly get back to us for further assistance.
Regards,
Sevvandhi N
SG
Sandeep G
September 1, 2021 07:07 AM UTC
Hi Sevvandhi,
I have tried with provided solution, I still get the same error.
below line worked for another input <ejs-autocomplete ref="outletInputSearch"
this.$refs.outletInputSearch.focusIn()
-----------------------------------------------------------------
In current case, I am supposed to focus autocomplete input once modal is opened.
<b-modal v-model="showAddBar" title="Item Details" hide-header hide-footer no-close-on-backdrop>
<!-- Modal content -->
<div class="modal-content-add">
<div class="row pb-4">
<div class="col">
<div class="autocomplete">
<ejs-autocomplete
:dataSource="itemCodeOptions"
:placeholder="'search product'"
:filtering="getProducts"
:value="itemAddObj.ItemCode"
@change="changeSelectedProduct"
ref="sideBarSearch"
></ejs-autocomplete>
</div>
</div>
current versions
SN
Sevvandhi Nagulan
Syncfusion Team
September 2, 2021 01:56 PM UTC
Hi Sandeep,
We checked your query. The provided code works as expected at our end. Please call the focusIn method in the open event of modal. Also make sure that, the component rendered in the page when accessing the instance of the component. Refer the below sample.
Sample link: https://codesandbox.io/s/vue-template-forked-jul2l
If still issue persists, kindly modify the above sample to validate the issue further at our end.
Regards,
Sevvandhi N
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SG Sandeep G
- Aug 30, 2021 10:31 AM UTC
- Sep 2, 2021 01:56 PM UTC