From 837dcc44feea6214198fe93f67fb123a7dea499c Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Wed, 2 Dec 2026 11:27:59 -0500 Subject: [PATCH 1/3] feat(surveys): add Skip button to optional survey questions Optional open text, rating, single choice and multiple choice questions now disable Submit until answered and show a separate Skip button. Adds the skipButtonText appearance field, parsed from the native appearance map. Co-Authored-By: Claude Opus 5.5 --- .changeset/quiet-owls-skip.md | 5 + .../models/posthog_display_survey.dart | 1 + .../posthog_display_survey_appearance.dart | 5 + .../src/surveys/models/survey_appearance.dart | 6 + .../src/surveys/widgets/choice_question.dart | 9 +- .../surveys/widgets/open_text_question.dart | 10 +- .../src/surveys/widgets/rating_question.dart | 9 +- .../src/surveys/widgets/survey_button.dart | 36 +++ .../test/survey_optional_choice_test.dart | 2 +- .../test/survey_optional_questions_test.dart | 14 +- .../test/survey_skip_button_test.dart | 243 ++++++++++++++++++ 11 files changed, 328 insertions(+), 12 deletions(-) create mode 100644 .changeset/quiet-owls-skip.md create mode 100644 posthog_flutter/test/survey_skip_button_test.dart diff --git a/.changeset/quiet-owls-skip.md b/.changeset/quiet-owls-skip.md new file mode 100644 index 000000000..1de4a2138 --- /dev/null +++ b/.changeset/quiet-owls-skip.md @@ -0,0 +1,5 @@ +--- +"posthog_flutter": minor +--- + +Optional open text, rating, single choice and multiple choice survey questions now show a separate Skip button below Submit, and Submit stays disabled until the question is answered. Skip sends the empty response (`""` for open text, no answer for the other types) and discards any answer already entered. Optional questions that submit automatically also show Skip. Adds `skipButtonText` to `PostHogDisplaySurveyAppearance`; the label defaults to "Skip". diff --git a/posthog_flutter/lib/src/surveys/models/posthog_display_survey.dart b/posthog_flutter/lib/src/surveys/models/posthog_display_survey.dart index 85f309361..49f96349c 100644 --- a/posthog_flutter/lib/src/surveys/models/posthog_display_survey.dart +++ b/posthog_flutter/lib/src/surveys/models/posthog_display_survey.dart @@ -107,6 +107,7 @@ class PostHogDisplaySurvey { borderColor: a['borderColor'] as String?, submitButtonColor: a['submitButtonColor'] as String?, submitButtonText: a['submitButtonText'] as String?, + skipButtonText: a['skipButtonText'] as String?, submitButtonTextColor: a['submitButtonTextColor'] as String?, textColor: a['textColor'] as String?, descriptionTextColor: a['descriptionTextColor'] as String?, diff --git a/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart b/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart index 1efbaaaea..d1151a30a 100644 --- a/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart +++ b/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart @@ -10,6 +10,7 @@ class PostHogDisplaySurveyAppearance { this.borderColor, this.submitButtonColor, this.submitButtonText, + this.skipButtonText, this.submitButtonTextColor, this.textColor, this.descriptionTextColor, @@ -37,6 +38,10 @@ class PostHogDisplaySurveyAppearance { final String? borderColor; final String? submitButtonColor; final String? submitButtonText; + + /// Label of the Skip button on optional questions. Null or empty shows + /// "Skip". + final String? skipButtonText; final String? submitButtonTextColor; final String? textColor; final String? descriptionTextColor; diff --git a/posthog_flutter/lib/src/surveys/models/survey_appearance.dart b/posthog_flutter/lib/src/surveys/models/survey_appearance.dart index 563053810..82d0075fe 100644 --- a/posthog_flutter/lib/src/surveys/models/survey_appearance.dart +++ b/posthog_flutter/lib/src/surveys/models/survey_appearance.dart @@ -37,6 +37,7 @@ class SurveyAppearance { this.backgroundColor = Colors.white, this.submitButtonColor = Colors.black, this.submitButtonText = 'Submit', + this.skipButtonText = 'Skip', this.submitButtonTextColor = Colors.white, this.descriptionTextColor = Colors.black, this.questionTextColor = Colors.black, @@ -66,6 +67,7 @@ class SurveyAppearance { final Color backgroundColor; final Color submitButtonColor; final String submitButtonText; + final String skipButtonText; final Color submitButtonTextColor; final Color descriptionTextColor; final Color questionTextColor; @@ -121,11 +123,15 @@ class SurveyAppearance { final inputTextColor = _colorFromHex(appearance?.inputTextColor) ?? _getContrastingTextColor(inputBackgroundColor); final inputPlaceholder = appearance?.placeholder; + final skipButtonText = appearance?.skipButtonText; return SurveyAppearance( backgroundColor: backgroundColor, submitButtonColor: submitButtonColor, submitButtonText: appearance?.submitButtonText ?? 'Submit', + skipButtonText: skipButtonText != null && skipButtonText.isNotEmpty + ? skipButtonText + : 'Skip', submitButtonTextColor: _colorFromHex(appearance?.submitButtonTextColor) ?? _getContrastingTextColor(submitButtonColor), descriptionTextColor: diff --git a/posthog_flutter/lib/src/surveys/widgets/choice_question.dart b/posthog_flutter/lib/src/surveys/widgets/choice_question.dart index 832ab433e..ad84d4aa2 100644 --- a/posthog_flutter/lib/src/surveys/widgets/choice_question.dart +++ b/posthog_flutter/lib/src/surveys/widgets/choice_question.dart @@ -78,7 +78,6 @@ class _ChoiceQuestionWidgetState extends State { !widget.hasOpenChoice; bool get _canSubmit { - if (widget.optional) return true; if (_selectedChoices.isEmpty) return false; if (widget.hasOpenChoice && _selectedChoices.contains(widget.choices.last) && @@ -208,6 +207,14 @@ class _ChoiceQuestionWidgetState extends State { appearance: widget.appearance, ), ], + if (widget.optional) + Padding( + padding: EdgeInsets.only(top: _shouldAutoSubmit ? 16 : 0), + child: SurveySkipButton( + onPressed: () => widget.onSubmit(null), + appearance: widget.appearance, + ), + ), ], ); } diff --git a/posthog_flutter/lib/src/surveys/widgets/open_text_question.dart b/posthog_flutter/lib/src/surveys/widgets/open_text_question.dart index ff4ba791a..81389ff67 100644 --- a/posthog_flutter/lib/src/surveys/widgets/open_text_question.dart +++ b/posthog_flutter/lib/src/surveys/widgets/open_text_question.dart @@ -33,8 +33,9 @@ class _OpenTextQuestionState extends State { String? _response; bool get _canSubmit { - if (widget.optional) return true; - return _response?.isNotEmpty == true; + final response = _response; + if (response == null) return false; + return widget.optional ? response.trim().isNotEmpty : response.isNotEmpty; } @override @@ -102,6 +103,11 @@ class _OpenTextQuestionState extends State { appearance: widget.appearance, enabled: _canSubmit, ), + if (widget.optional) + SurveySkipButton( + onPressed: () => widget.onSubmit(''), + appearance: widget.appearance, + ), ], ); }, diff --git a/posthog_flutter/lib/src/surveys/widgets/rating_question.dart b/posthog_flutter/lib/src/surveys/widgets/rating_question.dart index 52926ef4d..a46bdfd73 100644 --- a/posthog_flutter/lib/src/surveys/widgets/rating_question.dart +++ b/posthog_flutter/lib/src/surveys/widgets/rating_question.dart @@ -47,7 +47,6 @@ class _RatingQuestionState extends State { int? _rating; bool get _canSubmit { - if (widget.optional) return true; return _rating != null; } @@ -245,6 +244,14 @@ class _RatingQuestionState extends State { }, ), ], + if (widget.optional) + Padding( + padding: EdgeInsets.only(top: widget.skipSubmitButton ? 24 : 0), + child: SurveySkipButton( + onPressed: () => widget.onSubmit(null), + appearance: widget.appearance, + ), + ), ], ); } diff --git a/posthog_flutter/lib/src/surveys/widgets/survey_button.dart b/posthog_flutter/lib/src/surveys/widgets/survey_button.dart index 1273d68c4..d7f5a5627 100644 --- a/posthog_flutter/lib/src/surveys/widgets/survey_button.dart +++ b/posthog_flutter/lib/src/surveys/widgets/survey_button.dart @@ -1,6 +1,42 @@ import 'package:flutter/material.dart'; import '../models/survey_appearance.dart'; +class SurveySkipButton extends StatelessWidget { + const SurveySkipButton({ + super.key, + required this.onPressed, + this.appearance = SurveyAppearance.defaultAppearance, + }); + + final VoidCallback onPressed; + final SurveyAppearance appearance; + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: onPressed, + style: TextButton.styleFrom( + foregroundColor: appearance.questionTextColor, + minimumSize: const Size.fromHeight(44), + ), + child: Opacity( + opacity: 0.7, + child: Text( + appearance.skipButtonText, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13, + color: appearance.questionTextColor, + fontFamily: appearance.fontFamily, + decoration: TextDecoration.underline, + decorationColor: appearance.questionTextColor, + ), + ), + ), + ); + } +} + class SurveyButton extends StatelessWidget { const SurveyButton({ super.key, diff --git a/posthog_flutter/test/survey_optional_choice_test.dart b/posthog_flutter/test/survey_optional_choice_test.dart index 930d556b1..375e5f736 100644 --- a/posthog_flutter/test/survey_optional_choice_test.dart +++ b/posthog_flutter/test/survey_optional_choice_test.dart @@ -41,7 +41,7 @@ void main() { )); await tester.pumpAndSettle(); - await tester.tap(find.text('Submit')); + await tester.tap(find.text('Skip')); await tester.pumpAndSettle(); expect(responses, [null]); diff --git a/posthog_flutter/test/survey_optional_questions_test.dart b/posthog_flutter/test/survey_optional_questions_test.dart index 14b6a8ca0..72623cb5f 100644 --- a/posthog_flutter/test/survey_optional_questions_test.dart +++ b/posthog_flutter/test/survey_optional_questions_test.dart @@ -39,19 +39,19 @@ Future> pumpQuestion( } void main() { - testWidgets('optional open text can be submitted empty with its button label', + testWidgets('optional open text skip submits empty with its own label', (tester) async { final responses = await pumpQuestion(tester, { 'type': 'open', 'question': 'Anything else?', 'isOptional': true, - 'buttonText': 'Skip', + 'buttonText': 'Send it', }); final button = tester.widget( - find.widgetWithText(ElevatedButton, 'Skip'), + find.widgetWithText(ElevatedButton, 'Send it'), ); - expect(button.onPressed, isNotNull); + expect(button.onPressed, isNull); await tester.tap(find.text('Skip')); await tester.pumpAndSettle(); @@ -59,7 +59,7 @@ void main() { expect(responses, ['']); }); - testWidgets('optional rating can be submitted with no selection', + testWidgets('optional rating skip submits null with no selection', (tester) async { final responses = await pumpQuestion(tester, { 'type': 'rating', @@ -76,9 +76,9 @@ void main() { final button = tester.widget( find.widgetWithText(ElevatedButton, 'Next'), ); - expect(button.onPressed, isNotNull); + expect(button.onPressed, isNull); - await tester.tap(find.text('Next')); + await tester.tap(find.text('Skip')); await tester.pumpAndSettle(); expect(responses, [null]); diff --git a/posthog_flutter/test/survey_skip_button_test.dart b/posthog_flutter/test/survey_skip_button_test.dart new file mode 100644 index 000000000..892a3b9a5 --- /dev/null +++ b/posthog_flutter/test/survey_skip_button_test.dart @@ -0,0 +1,243 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:posthog_flutter/src/surveys/models/posthog_display_survey.dart'; +import 'package:posthog_flutter/src/surveys/models/survey_appearance.dart'; +import 'package:posthog_flutter/src/surveys/models/survey_callbacks.dart'; +import 'package:posthog_flutter/src/surveys/widgets/survey_bottom_sheet.dart'; + +Map openText({bool optional = true}) => { + 'type': 'open', + 'question': 'Question', + 'isOptional': optional, + }; + +Map rating({bool optional = true, bool? autoSubmit}) => { + 'type': 'rating', + 'question': 'Question', + 'isOptional': optional, + if (autoSubmit != null) 'skipSubmitButton': autoSubmit, + 'ratingType': 0, + 'scaleLowerBound': 1, + 'scaleUpperBound': 5, + 'lowerBoundLabel': 'Low', + 'upperBoundLabel': 'High', + }; + +Map choice( + String type, { + bool optional = true, + bool? autoSubmit, +}) => + { + 'type': type, + 'question': 'Question', + 'isOptional': optional, + if (autoSubmit != null) 'skipSubmitButton': autoSubmit, + 'choices': ['A', 'B'], + 'hasOpenChoice': false, + 'shuffleOptions': false, + }; + +Future> pumpQuestion( + WidgetTester tester, + Map question, { + Map? appearance, +}) async { + final responses = []; + final survey = PostHogDisplaySurvey.fromDict({ + 'id': 'skip-survey', + 'name': 'Skip', + 'questions': [question], + if (appearance != null) 'appearance': appearance, + }); + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: SurveyBottomSheet( + survey: survey, + appearance: SurveyAppearance.fromPostHog(survey.appearance), + onShown: (_) {}, + onClosed: (_) {}, + onResponse: (_, index, response) async { + responses.add(response); + return PostHogSurveyNextQuestion( + questionIndex: index, + isSurveyCompleted: true, + ); + }, + ), + ), + )); + await tester.pumpAndSettle(); + return responses; +} + +bool isSubmitEnabled(WidgetTester tester) { + final submit = find.widgetWithText(ElevatedButton, 'Submit'); + return tester.widget(submit).onPressed != null; +} + +Future answer(WidgetTester tester, String type) async { + switch (type) { + case 'open': + await tester.enterText(find.byType(TextField), 'hello'); + case 'rating': + await tester.tap(find.text('3')); + default: + await tester.tap(find.text('A')); + } + await tester.pumpAndSettle(); +} + +void main() { + final cases = <(String, Map, Object?)>[ + ('open', openText(), ''), + ('rating', rating(), null), + ('single_choice', choice('single_choice'), null), + ('multiple_choice', choice('multiple_choice'), null), + ]; + + for (final (type, question, emptyValue) in cases) { + group(type, () { + testWidgets('submit is disabled until answered', (tester) async { + await pumpQuestion(tester, question); + expect(isSubmitEnabled(tester), isFalse); + + await answer(tester, type); + expect(isSubmitEnabled(tester), isTrue); + }); + + testWidgets('skip sends the empty value', (tester) async { + final responses = await pumpQuestion(tester, question); + + await tester.tap(find.text('Skip')); + await tester.pumpAndSettle(); + + expect(responses, [emptyValue]); + }); + + testWidgets('skip after answering discards the answer', (tester) async { + final responses = await pumpQuestion(tester, question); + await answer(tester, type); + expect(find.text('Skip'), findsOneWidget); + + await tester.tap(find.text('Skip')); + await tester.pumpAndSettle(); + + expect(responses, [emptyValue]); + }); + + testWidgets('custom skip label replaces the default', (tester) async { + await pumpQuestion( + tester, + question, + appearance: {'skipButtonText': 'Not now'}, + ); + + expect(find.text('Not now'), findsOneWidget); + expect(find.text('Skip'), findsNothing); + }); + + testWidgets('empty skip label falls back to Skip', (tester) async { + await pumpQuestion( + tester, + question, + appearance: {'skipButtonText': ''}, + ); + + expect(find.text('Skip'), findsOneWidget); + }); + + testWidgets('required question has no skip button', (tester) async { + await pumpQuestion(tester, {...question, 'isOptional': false}); + + expect(find.text('Skip'), findsNothing); + expect(isSubmitEnabled(tester), isFalse); + }); + }); + } + + testWidgets('whitespace-only optional open text keeps submit disabled', + (tester) async { + await pumpQuestion(tester, openText()); + + await tester.enterText(find.byType(TextField), ' '); + await tester.pumpAndSettle(); + + expect(isSubmitEnabled(tester), isFalse); + }); + + testWidgets('optional open text submit sends the trimmed answer', + (tester) async { + final responses = await pumpQuestion(tester, openText()); + + await tester.enterText(find.byType(TextField), ' hello '); + await tester.pumpAndSettle(); + await tester.tap(find.text('Submit')); + await tester.pumpAndSettle(); + + expect(responses, ['hello']); + }); + + group('auto-submit', () { + testWidgets('optional rating shows skip without a submit button', + (tester) async { + final responses = await pumpQuestion(tester, rating(autoSubmit: true)); + + expect(find.text('Submit'), findsNothing); + await tester.tap(find.text('Skip')); + await tester.pumpAndSettle(); + + expect(responses, [null]); + }); + + testWidgets('optional single choice shows skip without a submit button', + (tester) async { + final responses = await pumpQuestion( + tester, + choice('single_choice', autoSubmit: true), + ); + + expect(find.text('Submit'), findsNothing); + await tester.tap(find.text('Skip')); + await tester.pumpAndSettle(); + + expect(responses, [null]); + }); + + testWidgets('required auto-submit rating has no skip button', + (tester) async { + await pumpQuestion(tester, rating(optional: false, autoSubmit: true)); + + expect(find.text('Skip'), findsNothing); + }); + }); + + group('skipButtonText parsing', () { + test('reads the appearance map key', () { + final survey = PostHogDisplaySurvey.fromDict({ + 'id': 'survey', + 'name': 'Survey', + 'questions': [openText()], + 'appearance': {'skipButtonText': 'Pass'}, + }); + + expect(survey.appearance?.skipButtonText, 'Pass'); + expect(SurveyAppearance.fromPostHog(survey.appearance).skipButtonText, + 'Pass'); + }); + + test('is null when the key is absent and resolves to Skip', () { + final survey = PostHogDisplaySurvey.fromDict({ + 'id': 'survey', + 'name': 'Survey', + 'questions': [openText()], + 'appearance': {'submitButtonText': 'Send'}, + }); + + expect(survey.appearance?.skipButtonText, isNull); + expect(SurveyAppearance.fromPostHog(survey.appearance).skipButtonText, + 'Skip'); + expect(SurveyAppearance.fromPostHog(null).skipButtonText, 'Skip'); + }); + }); +} From 027ab1aad163eb8c131cb6ad45e930f5ba6bc071 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 4 Dec 2026 07:52:33 -0500 Subject: [PATCH 2/3] fix(surveys): fall back to Skip for a whitespace-only label A blank skipButtonText now shows "Skip" instead of an empty button. Adds tests for optional choice questions with an open choice (Submit gating, Skip discarding the text, auto-submit), deselecting an optional rating or choice, and an optional link question having no Skip. Co-Authored-By: Claude Opus 5.5 --- .../posthog_display_survey_appearance.dart | 2 +- .../src/surveys/models/survey_appearance.dart | 2 +- .../test/survey_skip_button_test.dart | 99 ++++++++++++++++++- 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart b/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart index d1151a30a..331d9f179 100644 --- a/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart +++ b/posthog_flutter/lib/src/surveys/models/posthog_display_survey_appearance.dart @@ -39,7 +39,7 @@ class PostHogDisplaySurveyAppearance { final String? submitButtonColor; final String? submitButtonText; - /// Label of the Skip button on optional questions. Null or empty shows + /// Label of the Skip button on optional questions. Null or blank shows /// "Skip". final String? skipButtonText; final String? submitButtonTextColor; diff --git a/posthog_flutter/lib/src/surveys/models/survey_appearance.dart b/posthog_flutter/lib/src/surveys/models/survey_appearance.dart index 82d0075fe..72d3bd9eb 100644 --- a/posthog_flutter/lib/src/surveys/models/survey_appearance.dart +++ b/posthog_flutter/lib/src/surveys/models/survey_appearance.dart @@ -129,7 +129,7 @@ class SurveyAppearance { backgroundColor: backgroundColor, submitButtonColor: submitButtonColor, submitButtonText: appearance?.submitButtonText ?? 'Submit', - skipButtonText: skipButtonText != null && skipButtonText.isNotEmpty + skipButtonText: skipButtonText != null && skipButtonText.trim().isNotEmpty ? skipButtonText : 'Skip', submitButtonTextColor: _colorFromHex(appearance?.submitButtonTextColor) ?? diff --git a/posthog_flutter/test/survey_skip_button_test.dart b/posthog_flutter/test/survey_skip_button_test.dart index 892a3b9a5..c3f7d8a63 100644 --- a/posthog_flutter/test/survey_skip_button_test.dart +++ b/posthog_flutter/test/survey_skip_button_test.dart @@ -27,14 +27,15 @@ Map choice( String type, { bool optional = true, bool? autoSubmit, + bool openChoice = false, }) => { 'type': type, 'question': 'Question', 'isOptional': optional, if (autoSubmit != null) 'skipSubmitButton': autoSubmit, - 'choices': ['A', 'B'], - 'hasOpenChoice': false, + 'choices': openChoice ? ['A', 'Other'] : ['A', 'B'], + 'hasOpenChoice': openChoice, 'shuffleOptions': false, }; @@ -240,4 +241,98 @@ void main() { expect(SurveyAppearance.fromPostHog(null).skipButtonText, 'Skip'); }); }); + + testWidgets('whitespace-only skip label falls back to Skip', (tester) async { + await pumpQuestion(tester, openText(), + appearance: {'skipButtonText': ' '}); + + expect(find.text('Skip'), findsOneWidget); + }); + + for (final type in ['single_choice', 'multiple_choice']) { + group('optional $type with an open choice', () { + testWidgets('submit stays disabled until the open choice has text', + (tester) async { + await pumpQuestion(tester, choice(type, openChoice: true)); + + await tester.tap(find.text('Other:')); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isFalse); + expect(find.text('Skip'), findsOneWidget); + + await tester.enterText(find.byType(TextFormField), ' '); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isFalse); + + await tester.enterText(find.byType(TextFormField), 'Custom'); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isTrue); + }); + + testWidgets('skip discards the open choice text', (tester) async { + final responses = + await pumpQuestion(tester, choice(type, openChoice: true)); + + await tester.tap(find.text('Other:')); + await tester.pumpAndSettle(); + await tester.enterText(find.byType(TextFormField), 'Custom'); + await tester.pumpAndSettle(); + await tester.tap(find.text('Skip')); + await tester.pumpAndSettle(); + + expect(responses, [null]); + }); + }); + } + + testWidgets( + 'optional auto-submit single choice with an open choice shows submit and skip', + (tester) async { + await pumpQuestion( + tester, choice('single_choice', autoSubmit: true, openChoice: true)); + + expect(isSubmitEnabled(tester), isFalse); + expect(find.text('Skip'), findsOneWidget); + }); + + testWidgets('deselecting an optional rating disables submit again', + (tester) async { + await pumpQuestion(tester, rating()); + + await tester.tap(find.text('3')); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isTrue); + + await tester.tap(find.text('3')); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isFalse); + expect(find.text('Skip'), findsOneWidget); + }); + + testWidgets('deselecting an optional choice disables submit again', + (tester) async { + await pumpQuestion(tester, choice('single_choice')); + + await tester.tap(find.text('A')); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isTrue); + + await tester.tap(find.text('A')); + await tester.pumpAndSettle(); + expect(isSubmitEnabled(tester), isFalse); + expect(find.text('Skip'), findsOneWidget); + }); + + testWidgets('optional link question has no skip button', (tester) async { + await pumpQuestion(tester, { + 'type': 'link', + 'question': 'Check this out', + 'isOptional': true, + 'link': 'https://posthog.com', + 'buttonText': 'Submit', + }); + + expect(find.text('Skip'), findsNothing); + expect(isSubmitEnabled(tester), isTrue); + }); } From f6b9983f382160177c44d19789fc6d7d4cfce2a9 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 4 Dec 2026 09:26:51 -0500 Subject: [PATCH 3/3] chore: describe skip label without internal appearance class Co-Authored-By: Claude Opus 5.5 --- .changeset/quiet-owls-skip.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/quiet-owls-skip.md b/.changeset/quiet-owls-skip.md index 1de4a2138..8b6b6cd16 100644 --- a/.changeset/quiet-owls-skip.md +++ b/.changeset/quiet-owls-skip.md @@ -2,4 +2,4 @@ "posthog_flutter": minor --- -Optional open text, rating, single choice and multiple choice survey questions now show a separate Skip button below Submit, and Submit stays disabled until the question is answered. Skip sends the empty response (`""` for open text, no answer for the other types) and discards any answer already entered. Optional questions that submit automatically also show Skip. Adds `skipButtonText` to `PostHogDisplaySurveyAppearance`; the label defaults to "Skip". +Optional open text, rating, single choice and multiple choice survey questions now show a separate Skip button below Submit, and Submit stays disabled until the question is answered. Skip sends the empty response (`""` for open text, no answer for the other types) and discards any answer already entered. Optional questions that submit automatically also show Skip. The Skip label comes from the survey's `skipButtonText` appearance setting and defaults to "Skip".