From fa88185dee6cc18f74bc84dad4a5e4dae0eb7c62 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 3 Apr 2019 11:52:02 +0100 Subject: [PATCH 1/2] Include the current power level in the selector This ensures we always include the current power level in the power selector, even if it's greater than the level you're allowed to set yourself. This ensures the selector can display the current value correctly when disabled. Fixes https://github.com/vector-im/riot-web/issues/9340 --- src/components/views/elements/PowerSelector.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/PowerSelector.js b/src/components/views/elements/PowerSelector.js index 89d46de117..17af0dba55 100644 --- a/src/components/views/elements/PowerSelector.js +++ b/src/components/views/elements/PowerSelector.js @@ -74,7 +74,7 @@ module.exports = React.createClass({ // This needs to be done now because levelRoleMap has translated strings const levelRoleMap = Roles.levelRoleMap(newProps.usersDefault); const options = Object.keys(levelRoleMap).filter((l) => { - return l === undefined || l <= newProps.maxValue; + return l === undefined || l <= newProps.maxValue || l == newProps.value; }); const isCustom = levelRoleMap[newProps.value] === undefined; @@ -130,7 +130,7 @@ module.exports = React.createClass({ + value={String(this.state.customValue)} disabled={this.props.disabled} /> ); } else { // Each level must have a definition in this.state.levelRoleMap @@ -148,7 +148,7 @@ module.exports = React.createClass({ picker = ( + value={String(this.state.selectValue)} disabled={this.props.disabled}> {options} ); From b0f59007f33e2458617d51e3511fd826039262d4 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 4 Apr 2019 10:30:23 +0100 Subject: [PATCH 2/2] Clarify `level` variable name --- src/components/views/elements/PowerSelector.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/PowerSelector.js b/src/components/views/elements/PowerSelector.js index 17af0dba55..9b886e7cb3 100644 --- a/src/components/views/elements/PowerSelector.js +++ b/src/components/views/elements/PowerSelector.js @@ -73,8 +73,12 @@ module.exports = React.createClass({ _initStateFromProps: function(newProps) { // This needs to be done now because levelRoleMap has translated strings const levelRoleMap = Roles.levelRoleMap(newProps.usersDefault); - const options = Object.keys(levelRoleMap).filter((l) => { - return l === undefined || l <= newProps.maxValue || l == newProps.value; + const options = Object.keys(levelRoleMap).filter(level => { + return ( + level === undefined || + level <= newProps.maxValue || + level == newProps.value + ); }); const isCustom = levelRoleMap[newProps.value] === undefined;