Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form render issue - hide/show control #232

Open
hemendpatel opened this issue Apr 21, 2023 · 0 comments
Open

form render issue - hide/show control #232

hemendpatel opened this issue Apr 21, 2023 · 0 comments

Comments

@hemendpatel
Copy link

hemendpatel commented Apr 21, 2023

I'm using Form control and hide a control base on condition. It is working if I use tab to navigate or move focus between child control on a page but it redraw if I'm using down or up arrow for navigation. does any body use form control to handle visibility?

Controller :
export class LoginController {
view: LoginView

constructor() {
	Screen.terminal.windowTitle("Login");
	this.onChange = this.onChange.bind(this);

	this.view = new LoginView();

	this.view.form.labeledInputs.find((x: { key: string; }) => x.key === 'UserName').on('key', this.onChange);
	Screen.document.giveFocusTo(this.view.form);
}

onChange(value: any, match: any, data: any) {
	this.view.form.labeledInputs.find((x: { key: string; }) => x.key === 'bdate').hide()
}

};

View:
import Screen from '../screen'
const tkit = require("terminal-kit");
import { BaseView } from '../shared/base.view';
export class LoginView {
form: any
constructor() {
this.form = new tkit.Form({
parent: Screen.document.elements.core,
x: 1,
y: 1,
width: 40,
inputs: [
{
key: 'UserName',
label: 'Login: ',
content: '',
validator: { type: 'string' },
maxLength: 20,
},
{
key: 'Password',
echoChar: '*',
label: 'Password: ',
validator: { type: 'number' },
disabled: true
}
,
{
key: 'bdate',
label: 'Birth Date: ',
content: '',
validator: { type: 'string' },
maxLength: 20,
}
],
buttons: [
{
content: '',
value: 'ok'
},
{
content: '',
value: 'cancel'
}
]
});

	this.form.selectInputKeyBindings = {
		LEFT: 'previous',
		RIGHT: 'next',
		UP: 'previous',
		DOWN: 'next'
	};

}

};

Step to reproduce :

step 1:

image

Step 2: Press enter.
It will hide Birth date input control
image

Step 3: press tab
It will work without any issue

Issue
Step 4: instead of using tab, use down or up arrow.
image

it will display again.

anybody use form control in your application and noticed such issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant