mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Feature/#271 keyboard nav (#288)
* Initial stab at Tab/Enter key handlers for Slots - Added tabIndex="0" attribute for the Slot sections and for the <li> elements inside. * Set up refs for slot <li> elements to allow focus manipulation. * Added initial keyDown handlers for Enter and Tab keys. * Additional update for focus handling inside slot selection <ul> * Added Tab/Enter/Shift-Tab key handlers for Outfitting section. Needs some fine-tuning but is usable in current state * Added keydown handler for Empty module selection. ToDo: handlers for engineering sections * Cleanup * Update to add focus on Modifications icon and Enter key handler to open modifications menu * Updates to add keydown handlers for modifications menu, and tab/shift-tab/enter key handlers while mod menus are open. * Additional updates for keyDown handlers * Update to add tabindex=0 and Enter Key handling for specials menus. ToDo: keep focus inside specials menu until item is selected with Enter key. * Further updates for keyDown handler in Modifications menus. * Added keyDown handlers to full mod menu (when mod menu is opened and a mod has been previously selected) * Update to add shift-tab and tab focus handling for number editor fields * Additional tab/shift-tab handlers. Fixed bug with exp. effects being recaculated for every onBlur event. * Added check to bypass focus reset if change in component was due to change in modification value. * Additional updates to tab/shift-tab handlers for modifications menu. * more updates * "Final" updates and bug fixes - added code for cases where there were no specials. * Final updates to set focus to appropriate element when slot/mod menus are closed.
This commit is contained in:
@@ -14,7 +14,10 @@ export default class Modification extends TranslatedComponent {
|
||||
m: PropTypes.object.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
value: PropTypes.number.isRequired,
|
||||
onChange: PropTypes.func.isRequired
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onKeyDown: PropTypes.func.isRequired,
|
||||
modItems: PropTypes.array.isRequired,
|
||||
handleModChange: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -36,7 +39,6 @@ export default class Modification extends TranslatedComponent {
|
||||
*/
|
||||
_updateValue(value) {
|
||||
const name = this.props.name;
|
||||
|
||||
let scaledValue = Math.round(Number(value) * 100);
|
||||
// Limit to +1000% / -99.99%
|
||||
if (scaledValue > 100000) {
|
||||
@@ -57,9 +59,15 @@ export default class Modification extends TranslatedComponent {
|
||||
|
||||
/**
|
||||
* Triggered when an update to slider value is finished i.e. when losing focus
|
||||
*
|
||||
* pnellesen (24/05/2018): added value check below - this should prevent experimental effects from being recalculated
|
||||
* with each onBlur event, even when no change has actually been made to the field.
|
||||
*/
|
||||
_updateFinished() {
|
||||
this.props.onChange();
|
||||
if (this.props.value != this.state.value) {
|
||||
this.props.handleModChange(true);
|
||||
this.props.onChange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,9 +94,9 @@ export default class Modification extends TranslatedComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<div onBlur={this._updateFinished.bind(this)} className={'cb'} key={name}>
|
||||
<div onBlur={this._updateFinished.bind(this)} className={'cb'} key={name} ref={ modItem => this.props.modItems[name] = modItem }>
|
||||
<div className={'cb'}>{translate(name, m.grp)}{symbol}</div>
|
||||
<NumberEditor className={'cb'} style={{ width: '90%', textAlign: 'center' }} step={0.01} stepModifier={1} decimals={2} value={this.state.value} onValueChange={this._updateValue.bind(this)} />
|
||||
<NumberEditor className={'cb'} style={{ width: '90%', textAlign: 'center' }} step={0.01} stepModifier={1} decimals={2} value={this.state.value} onValueChange={this._updateValue.bind(this)} onKeyDown={ this.props.onKeyDown } />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user