shadcn.io is not affiliated with official shadcn/ui
File Conflict Dialog Block for React
A file-sync folder with its conflict alert shown open: the two copies of a spreadsheet side by side with when, who and how big, four ways to settle it, an Apply to all option, and the next conflict loading after each answer.
Installation
Overview
Settle two edits of one file by looking at both, with this sync conflict alert for React with Base UI. It opens from the Design handoff folder of Syncbarn, a file-sync app: the header holds an outline Resolve conflicts Button with a count, and the folder itself, a sync bar over a grid of eight file tiles with five of them marked, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Alert Dialog puts the two copies of the file in two cells, On this computer and In Syncbarn, each with the time it was saved in a time element, its size, who saved it and a drawn sheet whose edited rows are shaded. Under them four radio rows decide it: keep both, which saves yours as "name (conflict).xlsx", use this computer's, use Syncbarn's, or skip it. A checkbox applies the answer to every conflict that is left. Resolve, the only Shine Button, settles this file and loads the next one ("Conflict 2 of 5"); the tiles behind lose their marks and the sync bar counts down. For preview the alert is drawn open in place when the page loads; the header button opens the real Alert Dialog, with the same cells and the same choice. For file sync, shared drives, offline-first apps and any place two people edit one thing.
FAQ
Why is the alert already open, and what do I keep?
So you can see it without a click. On load the alert is a copy drawn in place over the folder: a native dialog element with the alertdialog role that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Resolve conflicts button opens the real Alert Dialog, modal, with its focus trap, Escape and focus on Cancel, and the copy stays closed until a reload. Both show the same ConflictFields component and share the block's state, so an answer picked in the copy is there in the real one. In your app keep the Alert Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.
What do the four answers do?
Keep both leaves two files: the Syncbarn copy keeps its name and this computer's is saved as "name (conflict).xlsx" beside it, so nothing is lost. Use this computer's and Use Syncbarn's replace the other copy, and each row says which one is overwritten. Skip this one leaves the file in conflict and moves it to the end of the line, so the count does not drop. Keep both is the answer chosen on every conflict, since it is the one that cannot lose work. Apply to all answers every conflict still waiting with the chosen answer; with Skip it closes and leaves them.
What does Resolve do here, and how do I wire it up?
Here it takes the file out of the list of conflicts, loads the next one, clears its mark on the drawn tile, counts the sync bar down and says in a polite status message what was kept and that nothing was synced. The five files, their times, sizes and edited rows are typed in CONFLICTS. In your app send the answer to your sync engine in resolve, keep the button busy until it confirms, and drop the file from the list only on success; show a failure in the alert and keep the file in conflict.
How are the two copies compared?
Side by side, with the same facts in the same places: the time in a time element, the size, the person who saved it, and a drawn sheet of six rows where the rows that copy changed are shaded, with the count in words ("2 rows edited") so the shading is never the only signal. In your app draw the sheet from a real diff, or swap it for a text diff or a thumbnail; keep the facts, since people choose by who and when.
Where does focus go, and how does it close?
The real alert is named by its title and described by its sentence, and it opens with focus on Cancel, so a stray Enter backs out. Escape and Cancel close it and return focus to Resolve conflicts; clicking outside does not close it, since a conflict has to be answered. Cancel is the focus target through initialFocus. The answers are native radio buttons in one group, so the arrow keys move between them. Once the last conflict is settled the button that opened the alert becomes All in sync, and focus moves to it. The copy shown on load moves no focus.
How does it look on a phone?
The copy shown on load docks to the foot of the page as a bottom sheet, its actions pinned at the bottom with Cancel under Resolve, and the cells and the answers scroll above them, one column each. The real alert keeps the Alert Dialog's own layout: a card as wide as the screen allows.
Related
- Pro
Sync Conflict Error
Files and dataA panel for two people who changed the same document: ruled rows for the fields that differ, each with Yours and Theirs as native radio cells, a Keep all toggle, a merged result that rebuilds as you choose, and the unchanged fields in a collapsible.
- Pro
Version History Dialog
Side sheetsA docs tool's version history sheet shown open: six versions with authors and times, the diff of the chosen one against the current text marked with underline, strike-through, glyphs and words, and a two-step restore.
- Pro
Confirm Action Dialog
Confirm and consentA newsletter editor with its publish confirmation shown open: an alert dialog that lists what happens to the issue, a box that remembers the answer, and a foot that gives the question back.
- Pro
A document drawer with its rename dialog shown open: the name beside a locked extension, four live checks with a character counter, the exact name it will be saved as, and a one-press fix when the name is taken.
- Pro
A desktop writing app with an update dialog shown open: the version change as a mono pair with its size, release notes grouped by kind in a one-open accordion, a remind-me choice, a skip link and a bounded pretend update that fills a progress line.
- Pro
A shared drive's document list with a full-screen viewer shown open: three drawn pages that turn with buttons or arrow keys, a Fit, 125% and 150% zoom, a details list, activity, a Copy link button and a Download that saves a text file.