mirror of https://github.com/zulip/zulip.git
settings: Fix save-discard widget handling for code block language.
The save-discard was not being hidden properly in the below case- - The "Default language for code blocks" setting was disabled initially (i.e. the "Disable" option was selected in the dropdown), meaning there was not default language set. - The setting is then udpated to "javascript" and the save-discard widget is shown as expected. - The setting is then again change to "Disable" option. The save-discard widget should have been hidden after the last step, but it does not. This was because while comparing the old and new value, the new value (obtained using get_dropdown_list_widget_setting_value) was computed as "null" while the old value (obtained from page_params) was an empty string "". This commit fixes the bug by changing get_dropdown_list_widget_setting_value to return empty string "", instead of null, when the "Disable" option is selected in the dropdown. The "get_dropdown_list_widget_setting_value" function was returning null previously, as we supported both null and empty string "" to represent the state of no language selected, with null being the initial value and empty string being used if user changed the setting to some language and then disabled it again. This was changed in #26275 and the state of not setting any default language for code blocks is now represented using empty string in all cases.
This commit is contained in:
parent
fc5b63e5cd
commit
7258a2caaf
|
@ -614,7 +614,7 @@ export function set_dropdown_list_widget_setting_value(property_name, value) {
|
|||
widget.render(value);
|
||||
}
|
||||
|
||||
export function get_dropdown_list_widget_setting_value($input_elem, for_api_data = true) {
|
||||
export function get_dropdown_list_widget_setting_value($input_elem) {
|
||||
const widget_name = extract_property_name($input_elem);
|
||||
const setting_widget = get_widget_for_dropdown_list_settings(widget_name);
|
||||
|
||||
|
@ -623,11 +623,7 @@ export function get_dropdown_list_widget_setting_value($input_elem, for_api_data
|
|||
return Number.parseInt(setting_widget.value(), 10);
|
||||
}
|
||||
|
||||
const setting_value = setting_widget.value();
|
||||
if (setting_value.length === 0 && !for_api_data) {
|
||||
return null;
|
||||
}
|
||||
return setting_value;
|
||||
return setting_widget.value();
|
||||
}
|
||||
|
||||
export function discard_property_element_changes(elem, for_realm_default_settings, sub) {
|
||||
|
@ -959,7 +955,7 @@ export function check_property_changed(elem, for_realm_default_settings, sub) {
|
|||
case "realm_signup_notifications_stream_id":
|
||||
case "realm_default_code_block_language":
|
||||
case "can_remove_subscribers_group":
|
||||
proposed_val = get_dropdown_list_widget_setting_value($elem, false);
|
||||
proposed_val = get_dropdown_list_widget_setting_value($elem);
|
||||
break;
|
||||
case "email_notifications_batching_period_seconds":
|
||||
proposed_val = get_time_limit_setting_value($elem, false);
|
||||
|
|
Loading…
Reference in New Issue