From f08ac68e0bdc5def47d4fe6e6b337e2b6528d50b Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 30 Jul 2019 10:12:51 -0400 Subject: [PATCH] refactor(searchbar): add deprecation warnings for showCancelButton (#18938) --- core/src/components/searchbar/searchbar.tsx | 8 ++++ .../searchbar/test/basic/index.html | 46 +++++++++---------- .../searchbar/test/standalone/index.html | 25 +++++----- .../searchbar/test/toolbar/index.html | 24 +++++----- 4 files changed, 57 insertions(+), 46 deletions(-) diff --git a/core/src/components/searchbar/searchbar.tsx b/core/src/components/searchbar/searchbar.tsx index b4a78e5888..bc11190ce9 100644 --- a/core/src/components/searchbar/searchbar.tsx +++ b/core/src/components/searchbar/searchbar.tsx @@ -170,6 +170,14 @@ export class Searchbar implements ComponentInterface { } componentDidLoad() { + if (this.showCancelButton === 'false' || this.showCancelButton === false) { + console.warn('The boolean values of showCancelButton are deprecated. Please use "never" instead of "false".'); + } + + if (this.showCancelButton === '' || this.showCancelButton === 'true' || this.showCancelButton === true) { + console.warn('The boolean values of showCancelButton are deprecated. Please use "focus" instead of "true".'); + } + this.positionElements(); this.debounceChanged(); diff --git a/core/src/components/searchbar/test/basic/index.html b/core/src/components/searchbar/test/basic/index.html index 8649a4dbfb..d53b876220 100644 --- a/core/src/components/searchbar/test/basic/index.html +++ b/core/src/components/searchbar/test/basic/index.html @@ -22,31 +22,31 @@
Search - Default
- +
Search - No Cancel Button
- + - +
Search - Always Show Cancel Button
- +
Search - Never Show Cancel Button
- +
Search - Show Cancel Button on Focus
Search - Cancel Button set to false
- + - +
Search - Cancel Button set to true
- +
Search - Disabled
@@ -54,45 +54,45 @@
Search - Danger
- +
Search - Custom Search Icon
- +
Search - Animated
- +
Search - Custom Placeholder
-
Search - Custom Cancel Button Danger
- +
Search - Value passed
- +
Search - Mode iOS
- +
Search - Mode MD
- +
Search - DebounceTime
-
Search - Animated and No Cancel
- +

@@ -117,17 +117,17 @@ // Toggle animated attribute const attrIsAnimated = dynamicAttr.getAttribute('animated') === 'true' ? false : true; dynamicAttr.setAttribute('animated', attrIsAnimated); - + // Toggle show-cancel-button attribute let attrShowCancel; const showCancelValue = dynamicAttr.getAttribute('show-cancel-button'); - + switch(showCancelValue) { - case true: + case true: case "true": attrShowCancel = false; break; - case false: + case false: case "false": attrShowCancel = 'always'; break; @@ -142,7 +142,7 @@ attrShowCancel = true; break; } - + dynamicAttr.setAttribute('show-cancel-button', attrShowCancel); // Toggle placeholder attribute diff --git a/core/src/components/searchbar/test/standalone/index.html b/core/src/components/searchbar/test/standalone/index.html index a9916e9d63..251d7bd308 100644 --- a/core/src/components/searchbar/test/standalone/index.html +++ b/core/src/components/searchbar/test/standalone/index.html @@ -15,13 +15,13 @@ @@ -29,7 +29,7 @@ id="dynamicProp" value="33" autocorrect="on" - show-cancel-button="true" + show-cancel-button="focus" autocomplete="on" spellcheck="false" type="number" @@ -42,11 +42,11 @@ autocomplete="off" spellcheck="true" type="text" - show-cancel-button="false"> + show-cancel-button="never"> @@ -55,26 +55,26 @@ value="mysearch" cancel-button-text="Really Long Cancel" color="dark" - show-cancel-button> + show-cancel-button="focus"> + show-cancel-button="never"> - + +