question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

custom-widget.tsx create a wrapper

See original GitHub issue

Are you requesting a feature, reporting a bug or asking a question?

Requesting a feature/asking a question

What is the current behavior?

What i need is a custom widget that enable itself when some props are selected and renders a wrapper (collapsible) on some questions when checked.

What is the expected behavior?

inside the render function, to have a second parameter : creator, to pass it down to my custom wrapper that basically do

const comp = ReactQuestionFactory.Instance.createQuestion(element.getTemplate(), {
		question: element,
		isDisplayMode: element.isReadOnly,
creator:????
	});
	return <div ref={elRef} className={"blu-question"}>
		{!element.preCheckHideCheckbox && elRef.current && ReactDOM.createPortal(<CheckBox value={open}
		                                                                                   className={className}/>, $(elRef.current).parents(".question").find(".sv_q_title .num")[0])}
		<Collapse in={!!collapseOpen}>
			<div className={className}>{comp}</div>
		</Collapse>
	</div>

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

export const SurveyCheckboxWidget = {
	name: "confirmWidget",
	
	render: function (element) {

		return <SurveyCheckboxQuestion element={element}></SurveyCheckboxQuestion>
	},
	
	isFit: function (question) {
		return question.preCheckDisable ||
				question.preCheckHideCheckbox ||
				question.preCheckCollapse;
	},
	widgetIsLoaded: function () {
	
		return true; //we do not require anything so we just return true.
	},
};

Thanks in advance

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
marc0n3commented, Apr 5, 2019

https://codepen.io/marcone/pen/JVXqYb

Maybe to do this, instead of using a widget, I need to override reactquestion.tsx:renderQuestionBody and wrap inside my component.

a working solution is:

//save the original
SurveyQuestion.renderQuestionBodyOrig = SurveyQuestion.renderQuestionBody
SurveyQuestion.renderQuestionBody = function (creator, question) {
	const useWrapper = question.preCheckDisable ||
			question.preCheckHideCheckbox ||
			question.preCheckCollapse;

	const questionBody = this.renderQuestionBodyOrig(creator, question);
	if (useWrapper) {
		return <SurveyCheckboxQuestion element={question}>{questionBody}</SurveyCheckboxQuestion>
	}
	return questionBody;
}

Do I need to close the bug?

0reactions
carllau999commented, May 26, 2019

@marc0n3

Not sure why but sometimes your solution gives me a Maximum call stack size exceeded error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build a Pluggable Web Widget: Part 1 | Mendix Documentation
Using a terminal or command line, navigate to your new Mendix app's folder, create a new folder named CustomWidgets, and start the generator ......
Read more >
How to Use Wrappers in Typescript React - Twilio
The wrapper is an object that is used to maximize code reuse and consistency. They are used to create and support basic UI...
Read more >
The One Widget (Part 2) - Esri Community
Wrapper.js - The equivalent to our custom Experience Builder widget, in that it "wraps" our custom component. index.tsx passes a reference ...
Read more >
Implementing a custom Netlify CMS widget - Softwire
Writing a custom widget in Typescript ... Great, so we created our widget file in src/cms/boundedList.tsx and immediately encountered a problem.
Read more >
ArcGIS API for JavaScript: Customizing Widgets - YouTube
You'll learn about widget view-models and how they make it easy to rewrite a widget's UI. We'll also cover using out-of-the-box themes, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found