Repository: streamlit/streamlit

Issue:
Color picker should only rerun script once pop-up is closed
Rationale: it's a common pattern to drag your mouse around the color picker to finally settle on the color you like. But as we do that, the script keeps rerunning, leading to a choppy / janky user experience. So let's change this behavior so the script only reruns when you close the pop-up, which is when you make the final decision on the color you want.


Discussion:

Resolving patch:
diff --git a/e2e/scripts/st_color_picker.py b/e2e/scripts/st_color_picker.py
--- a/e2e/scripts/st_color_picker.py
+++ b/e2e/scripts/st_color_picker.py
@@ -14,8 +14,8 @@
 
 import streamlit as st
 
-c1 = st.beta_color_picker("Default Color")
+c1 = st.color_picker("Default Color")
 st.write("Color 1", c1)
 
-c2 = st.beta_color_picker("New Color", "#EB144C")
+c2 = st.color_picker("New Color", "#EB144C")
 st.write("Color 2", c2)
diff --git a/lib/streamlit/__init__.py b/lib/streamlit/__init__.py
--- a/lib/streamlit/__init__.py
+++ b/lib/streamlit/__init__.py
@@ -156,10 +156,7 @@ def _update_logger():
 video = _main.video  # noqa: E221
 warning = _main.warning  # noqa: E221
 write = _main.write  # noqa: E221
-beta_color_picker = _main.beta_color_picker  # noqa: E221
-beta_container = _main.beta_container  # noqa: E221
-beta_expander = _main.beta_expander  # noqa: E221
-beta_columns = _main.beta_columns  # noqa: E221
+color_picker = _main.color_picker  # noqa: E221
 
 # Config
 
@@ -201,6 +198,10 @@ def wrapped(*args, **kwargs):
 
 
 beta_set_page_config = _beta_warning(set_page_config, "2021-01-06")
+beta_color_picker = _beta_warning(_main.color_picker, "January 28, 2021")
+beta_container = _main.beta_container  # noqa: E221
+beta_expander = _main.beta_expander  # noqa: E221
+beta_columns = _main.beta_columns  # noqa: E221
 
 
 def set_option(key, value):
diff --git a/lib/streamlit/elements/color_picker.py b/lib/streamlit/elements/color_picker.py
--- a/lib/streamlit/elements/color_picker.py
+++ b/lib/streamlit/elements/color_picker.py
@@ -6,7 +6,7 @@
 
 
 class ColorPickerMixin:
-    def beta_color_picker(dg, label, value=None, key=None):
+    def color_picker(dg, label, value=None, key=None):
         """Display a color picker widget.
 
         Note: This is a beta feature. See
@@ -33,7 +33,7 @@ def beta_color_picker(dg, label, value=None, key=None):
 
         Example
         -------
-        >>> color = st.beta_color_picker('Pick A Color', '#00f900')
+        >>> color = st.color_picker('Pick A Color', '#00f900')
         >>> st.write('The current color is', color)
 
         """


Test patch:
diff --git a/lib/tests/streamlit/color_picker_test.py b/lib/tests/streamlit/color_picker_test.py
--- a/lib/tests/streamlit/color_picker_test.py
+++ b/lib/tests/streamlit/color_picker_test.py
@@ -23,7 +23,7 @@
 class ColorPickerTest(testutil.DeltaGeneratorTestCase):
     def test_just_label(self):
         """Test that it can be called with no value."""
-        st.beta_color_picker("the label")
+        st.color_picker("the label")
 
         c = self.get_delta_from_queue().new_element.color_picker
         self.assertEqual(c.label, "the label")
@@ -32,7 +32,7 @@ def test_just_label(self):
     @parameterized.expand([("#333333", "#333333"), ("#333", "#333"), (None, "#000000")])
     def test_value_types(self, arg_value, proto_value):
         """Test that it supports different types of values."""
-        st.beta_color_picker("the label", arg_value)
+        st.color_picker("the label", arg_value)
 
         c = self.get_delta_from_queue().new_element.color_picker
         self.assertEqual(c.label, "the label")
@@ -41,9 +41,9 @@ def test_value_types(self, arg_value, proto_value):
     def test_invalid_value_type_error(self):
         """Tests that when the value type is invalid, an exception is generated"""
         with pytest.raises(StreamlitAPIException) as exc_message:
-            st.beta_color_picker("the label", 1234567)
+            st.color_picker("the label", 1234567)
 
     def test_invalid_string(self):
         """Tests that when the string doesn't match regex, an exception is generated"""
         with pytest.raises(StreamlitAPIException) as exc_message:
-            st.beta_color_picker("the label", "#invalid-string")
+            st.color_picker("the label", "#invalid-string")