diff --git a/src/bootstrap/Select.js b/src/bootstrap/Select.js
index 5fdbdc1..0292a2a 100644
--- a/src/bootstrap/Select.js
+++ b/src/bootstrap/Select.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
+ * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
@@ -18,20 +18,14 @@ Select.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
/** Help text message. */
helpText: PropTypes.string,
- /** Turns on/off alphabetical ordering of the Select options. */
- customOrder: PropTypes.bool,
};
-export function Select({ label, choices, helpText, customOrder, ...props }) {
+export function Select({ label, choices, helpText, ...props }) {
const uid = useUID();
- const keys = Object.keys(choices);
- if (!customOrder) {
- keys.sort((a, b) => a - b || a.toString().localeCompare(b.toString()));
- }
- const options = keys.map((key) => (
-
));
diff --git a/src/common/WiFiSettings/WiFiForm.js b/src/common/WiFiSettings/WiFiForm.js
index 8179f1b..5115a2a 100644
--- a/src/common/WiFiSettings/WiFiForm.js
+++ b/src/common/WiFiSettings/WiFiForm.js
@@ -64,6 +64,7 @@ DeviceForm.propTypes = {
channel: PropTypes.string.isRequired,
guest_wifi: PropTypes.object.isRequired,
encryption: PropTypes.string.isRequired,
+ available_bands: PropTypes.array.isRequired,
}),
formErrors: PropTypes.object.isRequired,
setFormValue: PropTypes.func.isRequired,
@@ -87,6 +88,7 @@ function DeviceForm({
...props
}) {
const deviceID = formData.id;
+ const bnds = formData.available_bands;
return (
<>
({
- devices: {
- [deviceIndex]: {
- hwmode: { $set: value },
- channel: { $set: "0" },
- htmode: {
- $set:
- value === "11a" ? "VHT80" : "HT20",
+ onChange={setFormValue((value) => {
+ // Get the last item in an array of available HT modes
+ const [best2] = bnds[0].available_htmodes.slice(-1);
+ const [best5] = bnds[1].available_htmodes.slice(-1);
+ return {
+ devices: {
+ [deviceIndex]: {
+ hwmode: { $set: value },
+ channel: { $set: "0" },
+ htmode: {
+ $set:
+ // Set HT mode depending on checked frequency
+ value === "11a" ? best5 : best2,
+ },
},
},
- },
- }))}
+ };
+ })}
{...props}
/>
@@ -209,7 +217,6 @@ function DeviceForm({
[deviceIndex]: { encryption: { $set: value } },
},
}))}
- customOrder
{...props}
/>
diff --git a/src/common/WiFiSettings/__tests__/WiFiSettings.test.js b/src/common/WiFiSettings/__tests__/WiFiSettings.test.js
index 72d99ae..a0cafbd 100644
--- a/src/common/WiFiSettings/__tests__/WiFiSettings.test.js
+++ b/src/common/WiFiSettings/__tests__/WiFiSettings.test.js
@@ -147,7 +147,7 @@ describe("", () => {
enabled: true,
guest_wifi: { enabled: false },
hidden: false,
- htmode: "HT20",
+ htmode: "VHT80",
hwmode: "11g",
id: 0,
password: "TestPass",
diff --git a/src/common/WiFiSettings/__tests__/__snapshots__/WiFiSettings.test.js.snap b/src/common/WiFiSettings/__tests__/__snapshots__/WiFiSettings.test.js.snap
index 24124bb..9210840 100644
--- a/src/common/WiFiSettings/__tests__/__snapshots__/WiFiSettings.test.js.snap
+++ b/src/common/WiFiSettings/__tests__/__snapshots__/WiFiSettings.test.js.snap
@@ -627,6 +627,11 @@ exports[` Snapshot one module enabled. 1`] = `
+ id=\\"8\\"
+ >
+
++
+
-+