How to implement react hook form using a inputbox component in react? - react-hook-form

I'm using a custom component with my inputbox in react, the problem is how can I implement the
{...register('field name')}? I tried to use ref={register} but there's an error because I'm using react hook form 7, this is applicable only on react hook form 6. Thanks!
<Inputbox
type='text'
placeholder='Email'
id='email'
name='email'
className={`w-full font-QuickSand font-semibold text-sm ${
errors.email
? 'bg-danger bg-opacity-10 border-danger focus:border-danger'
: ''
} pl-11 pt-4 pr-4 pb-4 border transition duration-600 ease-in-out focus:border-primary focus:outline-none`}
value={userInfo.email}
{...register('email')} <-- this is not working
onChange={handleOnChange}
/>

Related

vaadin 23 textfield set type

I'm using a vaadin TextField on mobile and want to change the input elements 'type' attribute to 'search' so that on mobile the search button shows up on the on screen keyboard.
The input field is in the shadow dom of the vaadin-text-field element:
<vaadin-text-field class="search" type="search" autocapitalize="none" placeholder="Search packages" style="width: 70%;">
<vaadin-button class="search-field-button" theme="icon primary" slot="prefix" tabindex="0" role="button">
<vaadin-icon class="search-field-icon" icon="vaadin:search" slot="prefix">
</vaadin-icon>
</vaadin-button>
<input slot="input" type="text" id="vaadin-text-field-0" placeholder="Search packages">
<label slot="label" id="label-vaadin-text-field-0" for="vaadin-text-field-0">
</label>
<div slot="error-message" id="error-message-vaadin-text-field-0" hidden="">
</div>
</vaadin-text-field>
Ideally, I want to set this from the java side.
There is a method on the TextField getElement().getShadowRoot() but this comes up empty.
I'm guessing I need some way to access the slot for the input field.
How do I do this?
There is no Java API for this, but you can do it with JavaScript call from Java side.
textField.getElement().executeJs("this.inputElement.setAttribute('type','search');");

Angular Mat DatePicker is broken

I am facing issue in rendering mat date picker. however it works fine when i reload the page. It only happens when i navigate from one tab to another.
<mat-form-field class="example-full-width">
<input matInput [matDatepicker]="picker" id="date" required [(ngModel)]="d.date" name="date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker ></mat-datepicker>
</mat-form-field><br />
Thanks in Advance!
I had this issue myself. In my case, I had a component with ViewEncapsulation.None loaded beforehand with css that broke the datepicker.

Mobile browser time inputs don't work inside vue element

I have a laravel webapp that uses multiple forms. I have recently introduced Vue.js v2 to deal with some specific custom input types which are working well.
Problem is that ordinary html5 input[type=time] inputs that are inside the vue instance element are not rendered properly in iOS safari/chrome - they appear as native timepickers but appear to have a blank value. When you click to change they do display the correct value.
I can workaround by using a custom vue component that just passes the value property into the vue instance but I figure I must be doing something wrong because I can't find a single mention of this anywhere.
I have managed to reproduce this on JSFiddle problem only appears in mobile browsers
html
<div id="app" style="background-color:lightblue; padding:30px">
<h3>This div is the Vue element</h3>
<form action="">
<p>
<label for="">Standard Input</label>
<input type="time" value="23:24:00" />
</p>
<p>
<label for="">Vue Component</label>
<vue-time value="13:45:00"></vue-time>
</p>
</form>
</div>
<div style="background-color:lightyellow; padding:30px">
<h3>This div is outside the Vue instance</h3>
<form action="">
<label for="">Standard Input</label>
<input type="time" value="23:24:00" />
</form>
</div>
js
Vue.component('vue-time', {
template: '<input type="time" :value="value">',
data() {
return {
value: ''
}
}
});
const vue = new Vue({
el: '#app',
data() {
return {
value: ''
}
}
});
I had a somewhat similar problem and I found this thread that helped me, see if it helps you:
https://forum.vuejs.org/t/solved-fixed-position-element-disappears-during-transition-on-mobile-browsers/8960
I would comment on your question instead of proposing this as an answer but I don't have the reputation to do so yet.

Show Search button on iOS keyboard using html input type=search in AngularJS app

In iOS 8 and above, to show the Search button on the iOS keyboard, you use the action attribute in the form. From Anton's answer here ... Show 'Search' button in iPhone/iPad Safari keyboard
<form action=".">
<input type="search" />
</form>
But this does not work when you are using an AngularJS form with ng-submit like this
<form action="." ng-submit="doSearch(searchtext)">
<input type="search" ng-model="searchtext" />
</form>
The action attribute breaks the Angular form submit.
Any suggestions on how to put a dummy action attribute and still get ng-submit to handle the form processing? Or any other solution that would show the iOS keyboard's search key with an AngularJS HTML5 form.
Just encountered the same problem, key here is that angular prevents default form submission only if no action specified, so if you want to specify one you need to preventDefault manually, which should be pretty easy.
This should work (worked for me):
<form action="." ng-submit="$event.preventDefault();doSearch(searchtext)">
<input type="search" ng-model="searchtext" />
</form>
Also note, that you will need to blur() your input field after you made a Search request in order to auto-hide keyboard.
Update:
With the latter this directive will help you:
.directive('prettySubmit', function () {
return function (scope, element, attr) {
var textFields = $(element).children('input');
$(element).submit(function(event) {
event.preventDefault();
textFields.blur();
});
};
})
I have placed preventDefault() in directive, so your form will look like this:
<form action="." ng-submit="doSearch(searchtext)" pretty-submit>
<input type="search" ng-model="searchtext" />
</form>
I encountered the same problem.
Finally I decided to use
<form action="{{'#/search/' + searchText }}">
Instead, and it works.

PhoneGap slider support not functioning properly

Working with PhoneGap attempting to add a label and slider to an iOS iPad application, both the label and the slider will not appear on the page. The following is the code intended to generate the display:
<div data-role="fieldcontain">
<label for="quantity">Number of Cones:</label>
<input type="range" name="quantity" id="quantity" value="5" min="1" max="10" />
</div>
The above snippet properly produces:
Number of Cones:
<------|------->
but fails to display the label box with quantity initialized to 5.
What is the cause of this issue?

Resources