Skip to content

Commit

Permalink
fixed issues with alert sliders in chrome #458
Browse files Browse the repository at this point in the history
  • Loading branch information
io53 committed Dec 11, 2024
1 parent 390400b commit 09e1e70
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/TextHelper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ export function uppercaseFirst(string) {

function addHighlight(str, highlightedText) {
return str.split(highlightedText).map((x, i, all) => {
return <>{x}{i === all.length - 1 ? null : <span style={{ color: "#f15a24" }}>{highlightedText}</span>}</>
return <span key={Math.random()}>{x}{i === all.length - 1 ? null : <span style={{ color: "#f15a24" }}>{highlightedText}</span>}</span>
})
}

export function addNewlines(str, newlineChar, highlightedText) {

return str.split(newlineChar || "\n").map((x, i, all) => {
x = addHighlight(x, highlightedText)
return <p style={{ marginTop: i > 0 ? 10 : undefined }} key={Math.random()}>{x}</p>
Expand Down
5 changes: 3 additions & 2 deletions src/components/AddSensorModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function AddSensorModal(props) {
}
const getPinInput = (i) => {
return <PinInputField ref={(input) => { pRef[i + ""] = input; }}
key={Math.random()}
onKeyDown={e => {
if (e.code === "Backspace") {
let idx = e.target.dataset.index
Expand All @@ -75,9 +76,9 @@ function AddSensorModal(props) {
if (text.indexOf("ruuvi.com/fi/tuki") !== -1) link = "ruuvi.com/fi/tuki"
var splitted = text.split(link)
if (splitted.length === 1) return text;
var out = [<span>{addNewlines(splitted[0])}</span>]
var out = [<span key={Math.random()}>{addNewlines(splitted[0])}</span>]
for (var i = 1; i < splitted.length; i++) {
out.push(<Link display="inline-block" href={"https://" + link} isExternal color="primary">{link}</Link>)
out.push(<Link key={Math.random()} display="inline-block" href={"https://" + link} isExternal color="primary">{link}</Link>)
}
return out;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/AlertSlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AlertSlider extends React.Component {
if (this.props.type === "temperature" || this.props.type === "pressure") {
max = uh.value(max)
min = uh.value(min)

}
var sliderValues = [min, max]
return <div style={{ display: 'flex', alignItems: 'center', marginLeft: 4, marginRight: 4 }}>
Expand Down Expand Up @@ -85,6 +85,7 @@ class AlertSlider extends React.Component {
renderThumb={({ props }) => (
<div
{...props}
key={props.key + this.props.type}
style={{
...props.style,
borderRadius: '6px',
Expand Down
3 changes: 1 addition & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,5 @@ root.render(
<App />
</ErrorView>
<ToastContainer />
</Suspense>,
document.getElementById('root')
</Suspense>
);
2 changes: 1 addition & 1 deletion src/states/Sensor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ class Sensor extends Component {
let latestValue = this.getLatestReading()[dataKey]
if (latestValue === undefined && x !== "offline") return null;
var alert = this.getAlert(x)
let key = alert ? alert.min + "" + alert.max + "" + alert.enabled.toString() + "" + alert.description : x
let key = alert ? alert.min + "" + alert.max + "" + alert.enabled.toString() + "" + alert.description + x : x
return <AlertItem key={key} alerts={this.props.sensor.alerts} alert={alert} sensor={this.props.sensor}
latestValue={latestValue}
noUpgradeButton={this.isSharedSensor() || !this.sensorHasData()}
Expand Down

0 comments on commit 09e1e70

Please sign in to comment.