Skip to content

Commit 8fac06c

Browse files
committed
make arrow visiable after sorting
1 parent f5420d2 commit 8fac06c

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

bigframes/display/table_widget.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,36 @@ function render({ model, el }) {
154154
// Create a span for the indicator
155155
const indicatorSpan = document.createElement("span");
156156
indicatorSpan.classList.add("sort-indicator");
157+
indicatorSpan.style.paddingLeft = "5px";
157158

158-
// Determine sort indicator
159+
// Determine sort indicator and initial visibility
159160
let indicator = "●"; // Default: unsorted (dot)
160161
if (currentSortColumn === columnName) {
161162
indicator = currentSortAscending ? "▲" : "▼";
163+
indicatorSpan.style.visibility = "visible"; // Sorted arrows always visible
164+
} else {
165+
indicatorSpan.style.visibility = "hidden"; // Unsorted dot hidden by default
162166
}
163167
indicatorSpan.textContent = indicator;
164168

165169
// Add indicator to the header, replacing the old one if it exists
166-
const existingIndicator = header.querySelector(".sort-indicator");
170+
const existingIndicator = headerDiv.querySelector(".sort-indicator");
167171
if (existingIndicator) {
168-
header.removeChild(existingIndicator);
172+
headerDiv.removeChild(existingIndicator);
169173
}
170-
header.appendChild(indicatorSpan);
174+
headerDiv.appendChild(indicatorSpan);
175+
176+
// Add hover effects for unsorted columns only
177+
header.addEventListener("mouseover", () => {
178+
if (currentSortColumn !== columnName) {
179+
indicatorSpan.style.visibility = "visible";
180+
}
181+
});
182+
header.addEventListener("mouseout", () => {
183+
if (currentSortColumn !== columnName) {
184+
indicatorSpan.style.visibility = "hidden";
185+
}
186+
});
171187

172188
// Add click handler for three-state toggle
173189
header.addEventListener(Event.CLICK, () => {

notebooks/dataframes/anywidget_mode.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
{
158158
"data": {
159159
"application/vnd.jupyter.widget-view+json": {
160-
"model_id": "46e7c5b5b5c64f92b445a6a30c4a44fe",
160+
"model_id": "7126a67d7aaf4b6c9055f80d358f6c15",
161161
"version_major": 2,
162162
"version_minor": 1
163163
},
@@ -192,8 +192,8 @@
192192
"### Sorting by Column\n",
193193
"You can sort the table by clicking on the headers of columns that have orderable data types (like numbers, strings, and dates). Non-orderable columns (like arrays or structs) do not have sorting controls.\n",
194194
"\n",
195-
"**Sorting indicators (●, ▲, ▼) are only visible when you hover over a column header.** The sorting control cycles through three states:\n",
196-
"- **Unsorted ():** The default state. Click the header to sort in ascending order.\n",
195+
"**Sorting indicators (▲, ▼) are always visible for sorted columns. The unsorted indicator (●) is only visible when you hover over an unsorted column header.** The sorting control cycles through three states:\n",
196+
"- **Unsorted (no indicator by default, ● on hover):** The default state. Click the header to sort in ascending order.\n",
197197
"- **Ascending (▲):** The data is sorted from smallest to largest. Click again to sort in descending order.\n",
198198
"- **Descending (▼):** The data is sorted from largest to smallest. Click again to return to the unsorted state."
199199
]
@@ -255,7 +255,7 @@
255255
{
256256
"data": {
257257
"application/vnd.jupyter.widget-view+json": {
258-
"model_id": "cc4b1c62308f4871be28c951737e5407",
258+
"model_id": "4f7ea9f8a4ef48539ccf72f3d36771f8",
259259
"version_major": 2,
260260
"version_minor": 1
261261
},
@@ -369,7 +369,7 @@
369369
{
370370
"data": {
371371
"application/vnd.jupyter.widget-view+json": {
372-
"model_id": "e3fbdff6dd1641aaaf6ed0b0fc4ca372",
372+
"model_id": "3327e2bdfd2849ff83a0f0bffd86163b",
373373
"version_major": 2,
374374
"version_minor": 1
375375
},
@@ -409,7 +409,7 @@
409409
"data": {
410410
"text/html": [
411411
"✅ Completed. \n",
412-
" Query processed 85.9 kB in 22 seconds of slot time.\n",
412+
" Query processed 85.9 kB in 24 seconds of slot time.\n",
413413
" "
414414
],
415415
"text/plain": [
@@ -456,7 +456,7 @@
456456
{
457457
"data": {
458458
"application/vnd.jupyter.widget-view+json": {
459-
"model_id": "8d3a5c29025848779533a64dadf8edb1",
459+
"model_id": "be49ea39d8784bc8bd55b7755e9eb2b1",
460460
"version_major": 2,
461461
"version_minor": 1
462462
},

0 commit comments

Comments
 (0)