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

Only set config value if it's different #363

Conversation

gsproston-scottlogic
Copy link
Contributor

Added a check to see if the new config value is different before setting the new value in the backend.

Copy link
Contributor

@heatherlogan-scottlogic heatherlogan-scottlogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me 🤓

Copy link
Member

@chriswilty chriswilty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to reject this PR, because it's a sticking plaster on a bigger problem: the use of a contenteditable div when a native textarea would be so much better, and give us so much more behaviour (and accessibility) for free.

}
}

function focusLost(event: React.FocusEvent<HTMLDivElement>) {
const value = event.target.innerText.trim();
// asynchronously set the configuration value
void setConfigurationValue(config.id, value);
setConfigurationValue(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This onBlur function would be completely unnecessary if we were using a native html input / textarea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, would this not still be required with input and textareas? To set the value on focus loss?

@gsproston-scottlogic
Copy link
Contributor Author

I'm inclined to reject this PR, because it's a sticking plaster on a bigger problem: the use of a contenteditable div when a native textarea would be so much better, and give us so much more behaviour (and accessibility) for free.

Ordinarily I'd be happy to swap out the contenteditable div here, but seeing as I'm off next week and the actual original issue is solved by this PR, it makes more sense to me to just merge this in and create a new issue to use a textarea element.

@chriswilty
Copy link
Member

@gsproston-scottlogic I remain unconvinced... It's still a sticking plaster, which will be reverted in the subsequent issue, so we'd be "fixing" it twice. We shouldn't even be firing an event in the first place if the value hasn't changed. We could always prioritise the proper fix and tackle it early next week?

@gsproston-scottlogic
Copy link
Contributor Author

@gsproston-scottlogic I remain unconvinced... It's still a sticking plaster, which will be reverted in the subsequent issue, so we'd be "fixing" it twice. We shouldn't even be firing an event in the first place if the value hasn't changed. We could always prioritise the proper fix and tackle it early next week?

Yeah I think that's fine. In that case would you mind updating the linked issue to include the contenteditable refactor?

@chriswilty
Copy link
Member

Created #371 for the more robust fix.

@gsproston-scottlogic
Copy link
Contributor Author

Closed as #354 will now be covered by #371

@gsproston-scottlogic gsproston-scottlogic deleted the 354-defences-successfully-configured-message-every-time-an-input-loses-focus branch October 18, 2023 14:13
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

Successfully merging this pull request may close these issues.

Defences Successfully Configured message every time an input loses focus
3 participants