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.

How to remove grid selection elements if not using popup form

See original GitHub issue

Version

I’m using 2.0.2

Test Environment

Chrome, MacOS, React v18

Current Behavior

Here’s a reproduction: https://codesandbox.io/s/gracious-lehmann-bmnuf0?file=/src/App.js

I’m new to TUI Calendar, but from reading the API/docs, I assume this is how it we’re supposed to create events without using the popup, using the onSelectDateTime and the events prop:

      onSelectDateTime={(event) => {
        setEvents([...events, { start: event.start, end: event.end }]);
      }}
      events={events}

But I don’t know how I can remove the selection element after

https://user-images.githubusercontent.com/732422/179431161-49e91881-4b9e-4c8b-af36-494b186295d0.mov

I’ve tried doing this:

        event.gridSelectionElements.forEach((element) => {
          // I don't know why this setTimeout is needed, but it doesn't work without
          setTimeout(() => {
            element.remove();
          }, 0);
        });

And it works, but if I change the events array, it re-renders the selection element.

Expected Behavior

I don’t believe it is a bug. I think it’s my knowledge gap that I need help with.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
adhrinaecommented, Jul 31, 2022

@gustavo-depaula

Here’s a simple example code with types. You can use the class component itself for the generic type for the useRef hook.

function App() {
  const calRef = useRef<Calendar | null>(null);

  const handleClear = () => {
    calRef?.current?.getInstance()?.clearGridSelections();
  };

  return (
    <div className="App">
      <button onClick={handleClear}>Clear</button>
      <Calendar ref={calRef} />
    </div>
  );
}
0reactions
gustavo-depaulacommented, Aug 18, 2022

You’re a genius @adhrinae!!

Thanks for all the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I prevent text/element selection with cursor drag
Dragging still invokes pointer events similar to text selection. Try applying user-select: none to an element and dragging over it. Sure there are...
Read more >
Popup Editing - DevExtreme Data Grid
Set the editing object's allowUpdating, allowAdding, and allowDeleting properties to true. DataGrid uses the DevExtreme Form and Popup components to display the ...
Read more >
Grid Selection - Telerik UI for Blazor - Documentation
In Inline EditMode and PopUp EditMode selection can be done by clicking on the desired row or by using a <GridCheckboxColumn /> ....
Read more >
Configure pop-ups—ArcGIS Pro | Documentation
These elements do not have a visible border. Element choices are listed as buttons at the top of the pane. Click an element...
Read more >
Form Grid - Knowledge Base for DX 7 - Joget | COMMUNITY
If the popup form has a grid element(s), this option will delete the inner grid data. ... These 3 options: (Delete Associated Grid...
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